Skip to content

AddFeatureManagement doesn't Register a Custom Configuration #546

Closed

Description

@daniell-reeco

Nuget version affected: 4.2.0 (worked in 4.0.0 until nuget updated)

In my Program.cs:
builder.Services.AddFeatureManagement(builder.Configuration.GetSection("FeatureFlags"));

GetSection confirmed to retrieve the configuration from appsettings.json which is:
"FeatureFlags": { "UseReecoUsers": true }

but when calling IsEnabledAsync with the manager I received the following log:
"The feature definition for the feature 'UseReecoUsers' was not found"

When changing the feature flag section to:
"FeatureManagement": { "UseReecoUsers": true }

and changing the line in Program.cs to:
builder.Services.AddFeatureManagement(/*builder.Configuration.GetSection("FeatureFlags")*/);

it identifed the feature flag.

Activity

  1. micheltol commented on Jun 30, 2025

    @micheltol

    I can confirm this issue. It worked with version 4.1.0

  2. zhiyuanliang-ms commented on Jun 30, 2025

    @zhiyuanliang-ms
    Member

    Hi, Michel Tol (@micheltol) daniell-reeco
    I am sorry about this issue. This is an oversight. It is a bug introduced in 4.2.0.

    In 4.2.0, we added an enhancement #536 that we will merge Microsoft feature flags from different configuration sources.

    This enhancement will make the operation to GetMicrosoftFeatureDefinitionSections becomes more time-consuming.
    Before 4.2.0, we will get all configuration sections for feature definitions and find the feature flags among them each time when there is no cache. code
    In 4.2.0, to improve the performance, we will cache all configuration sections for feature definitions when constructing the ConfigurationFeatureDefinitionProvider. code. So, until the configuration is changed, we only get all configuration sections for feature definitions for once and it happens in the constructor of the ConfigurationFeatureDefinitionProvide.

    However,

    builder.Services.AddFeatureManagement(builder.Configuration.GetSection("FeatureFlags"));

    the above the usage is something we called RootConfigurationFallback. It will only be set to true when you provide an IConfiguration when calling AddFeatureManagement. The RootConfigurationFallbackEnabled property of ConfigurationFeatureDefinitionProvider is set to true after the constructor of the ConfigurationFeatureDefinitionProvider. code So, for the first time we call GetDotnetFeatureDefinitionSections in the constructor, the RootConfigurationFallbackEnabled will not be respected. This caused the issue.

    I have sent out a bug fix PR: #547

    Put more backgrounds here:
    We have some back and forth on this feature. we even removed this feature in 3.0.0 and added it back in 3.1.0. #308 #312

    You might have question: why we don't use init key word. Here is the reason.

  3. jimmyca15 commented on Jun 30, 2025

    @jimmyca15
    Member

    Thanks for reporting this issue. Package version 4.2.0 has been unlisted

  4. zhiyuanliang-ms commented on Jul 10, 2025

    @zhiyuanliang-ms
    Member

    daniell-reeco Michel Tol (@micheltol) 4.2.1 is released. It should fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions