You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Faced with the issue when due to the overriding configuration ConfigurationFeatureDefinitionProvider will falsely enable a feature flag.
Example setup:
appsettings.json
Expected result: feature manager returns False for IsEnabledAsync("FeatureA")
Test example:
usingMicrosoft.Extensions.Configuration;usingMicrosoft.Extensions.DependencyInjection;usingMicrosoft.FeatureManagement;namespaceTestProject{publicclassTests{[Test]publicasyncTaskFeatureWithDirectValueMustBeDisabled(){varconfigKeys=newDictionary<string,string?>{["FeatureManagement:FeatureA"]="False",["FeatureManagement:FeatureA:RequirementType"]="All",["FeatureManagement:FeatureA:EnabledFor:0:Name"]="AlwaysOn"};varcfg=newConfigurationBuilder().AddInMemoryCollection(configKeys).Build();varsc=newServiceCollection();sc.AddFeatureManagement();sc.AddSingleton<IConfiguration>(cfg);varserviceProvider=sc.BuildServiceProvider();varfeatureManager=serviceProvider.GetRequiredService<IFeatureManager>();varfeatureState=awaitfeatureManager.IsEnabledAsync("FeatureA");Assert.IsFalse(featureState,"FeatureA must be disabled as it's Value is False");}}}
Actual result:: featureManager.IsEnabledAsync("FeatureA") returns True
Root cause: ConfigurationFeatureDefinitionProvider doesn't distinguish if there is an actual False value set or value can't be parsed in the method ParseDotnetSchemaFeatureDefinition:
Hi, @DenomikoN Sorry for the inconvenience. I think the key issue here is that when merging different configuration source, the IConfiguration system will produce the below configuration
This should not be a valid feature flag declaration.
To work around with the current behavior of IConfiguration, I suggest you switch to our new Microsoft feature management schema (json schema is here)
Using this schema can kind of mitigate the merging configuration issue.
From our side, the root cause you mentioned is correct. Do you think when ConfigurationFeatureDefinitionProvider meets some feature flag declaration which is invalid or cannot be parsed, it should throw exception or log warning?
Faced with the issue when due to the overriding configuration ConfigurationFeatureDefinitionProvider will falsely enable a feature flag.
Example setup:
appsettings.json
Overriden by production configuration:
appsettings.production.json
That produces the following configuration key-values pairs:
Expected result: feature manager returns False for IsEnabledAsync("FeatureA")
Test example:
Actual result:: featureManager.IsEnabledAsync("FeatureA") returns True
Root cause: ConfigurationFeatureDefinitionProvider doesn't distinguish if there is an actual False value set or value can't be parsed in the method ParseDotnetSchemaFeatureDefinition:
The text was updated successfully, but these errors were encountered: