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:
|
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.
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
DefaultNameSelectorwithout first registering a Provider.Steps to reproduce
If you call
AddOpenFeatureand specify a Policy Name Selector, noIFeatureClientcan be resolved from the dependency injection scope.I suspect the issue is here:
dotnet-sdk/src/OpenFeature.DependencyInjection/OpenFeatureBuilderExtensions.cs
Lines 229 to 232 in 417f3fe
If no name is configured, we attempt to resolve any
IFeatureClients already registered. However, this just ends up calling itself.