Closed davidstarkcab closed 6 months ago
What version did you upgrade from, and is the same setup working with the old version?
Hi, @davidstarkcab
I have reproduced the bug. This bug is introduced by 3.3.0. Sorry for the inconvenience.
The reason of this bug is that in v3.3.0, we enhance the TimeWindowFilter
to support recurrence settings. To optimize the recurring time window evaluation, we used a memory cache in TimeWindowFilter
, which cause the registeration of TimeWindowFilter
is slightly different from other built-in filters. We used a new overload of AddFeatureFilter
method. This caused TimeWindowFilter
being registered multiple times and the feature manager will get duplicated filter metadata of it. Then, AmbiguousFeatureFilter exception is thrown.
To resolve your problem, please downgrade to 3.2.0 or you can change this line
builder.Services.AddFeatureManagement().AddFeatureFilter<ContextualTargetingFilter>().AddFeatureFilter<TimeWindowFilter>().AddFeatureFilter<PercentageFilter>();
to
builder.Services.AddFeatureManagement();
Starting from 3.0.0, ContextualTargetingFilter
, TimeWindowFilter
and PercentageFilter
are registered within the AddFeatureManagement
call. For more details, see here
So you no longer need to register them by yourself. We mention this in the public doc and also in the README.
In the README, we said
There a few feature filters that come with the
Microsoft.FeatureManagement
package:PercentageFilter
,TimeWindowFilter
,ContextualTargetingFilter
andTargetingFilter
. All filters, except for theTargetingFilter
, are added automatically when feature management is registered.
This is a mistake, I should bold this to catch more eyes. I will update the README and fix the bug soon.
What version did you upgrade from, and is the same setup working with the old version?
3.2.0 and its the same setup
@zhiyuanliang-ms Thanks!
@jimmyca15
Our previous way to avoid duplicated registeration is to check the implementationType of existing ServiceDescriptor in the service collection. Now, time window filter is registered through implementationFactory, its descriptor's implementationType is null.
ServiceDescriptor doesn't allow us to set implementationType while using implementationFactory. https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicedescriptor?view=net-6.0
I didn't come up a graceful solution. Currently, I have two was in my mind:
Remove the public Cache property of TimeWindowFilter and put it into the constructor
Remove the overload of AddFeatureFilter
Ignore TimeWindowFilter in AddFeatureFilter
The FeatureManagementBuilder is internal, so our implementation of AddFeatureFilter
Hi, @davidstarkcab
Have you tried removing all AddFeatureFilter
calls to register built-in feature filters? Did it work for you?
@zhiyuanliang-ms Yes, now it works perfectly! Many thanks!
Microsoft.FeatureManagement
3.3.1 has been released.
Hello!
After we updated the NuGet package Microsoft.FeatureManagement.AspNetCore to version 3.3.0, we started receiving the following exception: "Multiple feature filters match the configured filter named 'Microsoft.TimeWindow'" whenever we have multiple feature toggles activated with Microsoft.TimeWindow.
This is how we configure it:
Here is how we encounter the error: