-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Observed behavior
The InMemoryProvider allows you to specify a contextEvaluator which you can use to dynamically pick or chose the variant the InMemoryProvider returns based on the context. Consider an InMemoryFlag that will return two possible variants from the contextEvaluator:
{
"boolean-targeted-zero-flag": {
"contextEvaluator": "email == '[email protected]' ? 'zero' : ''",
"defaultVariant": "zero",
"variants": {
"non-zero": true,
"zero": false
}
}
}If the predicate returns false, we get a variant of "" which is not registered as a variant for the flag.
dotnet-sdk/src/OpenFeature/Providers/Memory/Flag.cs
Lines 59 to 63 in 51aefbc
| var variant = this._contextEvaluator.Invoke(evaluationContext ?? EvaluationContext.Empty); | |
| if (!this._variants.TryGetValue(variant, out value)) | |
| { | |
| throw new GeneralException($"variant {variant} not found"); | |
| } |
This causes OpenFeature to return the an error, meaning the API returns the default parameter as provided to the client. It does not return the default variant as configured in the provider.
var result = await client.GetBooleanDetailsAsync("boolean-targeted-zero-flag", false)This result will be false, however the InMemoryProvider is configured to return the default variant "zero" which is true.
Expected Behavior
I found this while adding the remaining e2e tests as described in the specification. Specifically, the Null context values scenario and the Empty evaluation context scenario.
These e2e test cases expect the default variant, as configured by the InMemoryProvider, to be returned. Not the default value provided to the client when evaluating the flag.
var result = await client.GetBooleanDetailsAsync("boolean-targeted-zero-flag", false)The result is expected to return true, but instead returns false when configured with the boolean-targeted-zero-flag flag above.
The Java SDK handles this as expected in the gherkin file.
Steps to reproduce
No response