-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Observed behavior
If you use the OpenFeature Dependency Injection to setup a Policy, and you fail to specify a name in DefaultNameSelector
function, the application will hang while infinitely trying to resolve IFeatureClient
.
Expected Behavior
Specifying no name when configuring a DefaultNameSelector
should resolve the default IFeatureClient
.
Steps to reproduce
If you call AddOpenFeature
and specify a Policy Name Selector which returns null, no IFeatureClient
can be resolved from the dependency injection scope.
builder.Services.AddOpenFeature(featureBuilder =>
{
featureBuilder
.AddHostedFeatureLifecycle()
.AddInMemoryProvider("InMemory", _ => new Dictionary<string, Flag>()
{
{
"welcome-message", new Flag<bool>(
new Dictionary<string, bool> { { "show", true }, { "hide", false } }, "show")
}
})
.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 IFeatureClient
s already registered. However, this just ends up calling itself.