microsoft / FeatureManagement-Dotnet

Microsoft.FeatureManagement provides standardized APIs for enabling feature flags within applications. Utilize this library to secure a consistent experience when developing applications that use patterns such as beta access, rollout, dark deployments, and more.
MIT License
1.02k stars 111 forks source link

No instance of ITargetingContextAccessor is available for variant assignment. #425

Closed joacar closed 4 months ago

joacar commented 4 months ago

Hi

In my production logs I see this warning message No instance of ITargetingContextAccessor is available for variant assignment. from namespace Microsoft.FeatureManagement.FeatureManager.

NuGet Microsoft.FeatureManagment.AspNetCore::3.2.0

// From JetBrains decompiled assembly
[assembly: Extension]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyDescription("Microsoft.FeatureManagement.AspNetCore provides a way to develop and expose application functionality based on features. Many applications have special requirements when a new feature is developed such as when the feature should be enabled and under what conditions. This library provides a way to define these relationships, and also integrates into common ASP.NET Core code patterns to make exposing these features possible.")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: AssemblyInformationalVersion("4.0.0-preview2+5c2af2c403c2f1098102a797abb83805379b7652")]
[assembly: AssemblyProduct("Microsoft.FeatureManagement.AspNetCore")]
[assembly: AssemblyTitle("Microsoft.FeatureManagement.AspNetCore")]
[assembly: AssemblyVersion("4.0.0.0")]

dotnet

>dotnet --version
8.0.101
>dotnet --list-sdks
7.0.305 [/usr/local/share/dotnet/sdk]
8.0.100-preview.7.23376.3 [/usr/local/share/dotnet/sdk]
8.0.101 [/usr/local/share/dotnet/sdk]
rossgrambo commented 4 months ago

Hello @joacar!

That error is only possible in 4.0.0-preview and above. I see 4.0.0-preview2 in your log which sounds like your app might have had the FeatureManagement package be updated to the preview version. If this wasn't intentional, you may want to go back to stable 3.2.0.

That warning means there was no ITargetingContextAccessor defined. This means TargetingContext can't be automatically determined for the given user. This only matters if you're using TargetingFilters or the preview feature Variants.

Either way, us logging this warning here is misleading, it should happen only during variant assignment. So thank you for reporting it!

joacar commented 4 months ago

Thanks I'll check the version of the NuGet package so it's really 3.2.0

zhiyuanliang-ms commented 4 months ago

Hi, @joacar Did you confirm that the problem was caused by the package version?

joacar commented 4 months ago

Sorry I forgot to reply! I'm quite sure I haven't seen it, let me verify later this evening.

Cheers

joacar commented 4 months ago

Problem resolved!

zhiyuanliang-ms commented 4 months ago

@joacar Glad to hear that. I will close this issue.