-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Not necessarily a bug, but rather an opportunity to improve the dependency injection experience.
If you calling AddOpenFeature and inject some EvaluationContext (see code snippet below) when resolving IFeatureClient a System.InvalidOperationException: Sequence contains no elements is thrown in OpenFeatureServiceCollectionExtensions.cs.
dotnet-sdk/src/OpenFeature.DependencyInjection/OpenFeatureServiceCollectionExtensions.cs
Lines 52 to 53 in 417f3fe
| var options = provider.GetRequiredService<IOptions<OpenFeatureOptions>>().Value; | |
| return options.ProviderNames.First(); |
Code to reproduce the exception
builder.Services.AddOpenFeature(featureBuilder =>
{
featureBuilder
.AddHostedFeatureLifecycle()
.AddContext(ctx => ctx.Set("region", "euw"));
});Is there a way we could throw an exception earlier, like say during Startup, to say that OpenFeature with Dependency Injection has not been setup correctly? Or should it fail more silently, and fallback to any default variants configured by developers?