Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/Microsoft.FeatureManagement/FeatureManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,6 @@ private async ValueTask<bool> IsEnabledAsync<TContext>(FeatureDefinition feature
}
else
{
//
// Ensure no conflicts in the feature definition
if (featureDefinition.RequirementType == RequirementType.All && _options.IgnoreMissingFeatureFilters)
{
throw new FeatureManagementException(
FeatureManagementError.Conflict,
$"The 'IgnoreMissingFeatureFilters' flag cannot be used in combination with a feature of requirement type 'All'.");
}

//
// If the requirement type is all, we default to true. Requirement type All will end on a false
enabled = featureDefinition.RequirementType == RequirementType.All;
Expand Down Expand Up @@ -491,6 +482,15 @@ private async ValueTask<bool> IsEnabledAsync<TContext>(FeatureDefinition feature

Logger?.LogWarning(FeatureFilterNotFoundError, featureFilterConfiguration.Name, featureDefinition.Name);

//
// If requirement type is All, a missing filter means the feature cannot be enabled
if (featureDefinition.RequirementType == RequirementType.All)
{
enabled = false;

break;
}

continue;
}

Expand Down
10 changes: 5 additions & 5 deletions tests/Tests.FeatureManagement/FeatureManagementTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ public async Task UsesRequirementType()
}

[Fact]
public async Task RequirementTypeAllExceptions()
public async Task RequirementTypeAllWithIgnoreMissingFeatureFilters()
{
IConfiguration config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();

Expand All @@ -816,12 +816,12 @@ public async Task RequirementTypeAllExceptions()

IFeatureManager featureManager = serviceProvider.GetRequiredService<IFeatureManager>();

//
// AllFilterFeature has RequirementType.All with missing filters.
// With IgnoreMissingFeatureFilters enabled, the feature should be treated as disabled.
string allFilterFeature = Features.AllFilterFeature;

await Assert.ThrowsAsync<FeatureManagementException>(async () =>
{
await featureManager.IsEnabledAsync(allFilterFeature);
});
Assert.False(await featureManager.IsEnabledAsync(allFilterFeature));
}

[Fact]
Expand Down
Loading