-
Notifications
You must be signed in to change notification settings - Fork 22
Closed
Copy link
Labels
area: dependency-injectionImprovements or bugs do DIImprovements or bugs do DIgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededtype: bugSomething isn't workingSomething isn't working
Milestone
Description
Observed behavior
If you use the OpenFeature Dependency Injection to setup a Policy, and you fail to register any Providers, the code will freeze when trying to resolve IFeatureClient.
Expected Behavior
Adding a Policy and DefaultNameSelector without first registering a Provider.
Steps to reproduce
If you call AddOpenFeature and specify a Policy Name Selector, no IFeatureClient can be resolved from the dependency injection scope.
builder.Services.AddOpenFeature(featureBuilder =>
{
featureBuilder
.AddPolicyName(policy =>
{
policy.DefaultNameSelector = provider =>
{
return null;
};
});
});I suspect the issue is here:
dotnet-sdk/src/OpenFeature.DependencyInjection/OpenFeatureBuilderExtensions.cs
Lines 229 to 232 in 417f3fe
| if (name == null) | |
| { | |
| return provider.GetRequiredService<IFeatureClient>(); | |
| } |
If no name is configured, we attempt to resolve any IFeatureClients already registered. However, this just ends up calling itself.
Metadata
Metadata
Assignees
Labels
area: dependency-injectionImprovements or bugs do DIImprovements or bugs do DIgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededtype: bugSomething isn't workingSomething isn't working