Skip to content

[BUG] Providing a Policy Name Selector without a Provider causes an infinite loop #543

@kylejuliandev

Description

@kylejuliandev

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.

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions