-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Inconsistent error behavior between Resolve<T> and ResolveAll during flagd runtime #1481
Comments
One way to fix this would be to modify
This would require adding the flag type to metadata, possibly during evaluation in
My question is, can we do that or would that be considered a breaking change and should be added as a new configuration option? |
This is a somewhat interesting question; on the one hand, this flag configuration violates the JSON schema. So, this is a user error in a certain way, but it can happen, and we should (even if we might come to the conclusion it is intended) do something. I am currently torn here a little bit. What our expected behavior is. I think that the I want to ask if we should also evaluate whether a change in ResolveAll's behavior could reduce the pain or solve this problem. Maybe generalizing the return value and letting the implementor decide how he wants to use this type could be feasible. Sadly, I am not profound enough with the What if we take the route of information and use the metadata, hooks, special events, and logs to inform about inconsistencies? |
Perhaps we could support a flag type in the flag definition. We're doing something similar in the code gen schema here. This would have to be optional, but we could use it to validate all the values during initialization. |
I do think that adding a flag type to the schema is something we should also do. However, as @beeme1mr says, it will have to be optional and so there still will be users who don't have it in their flag config. We could (and IMHO should) also add an option for stricter validation during flag sync (erroring rather than warning) but that also will not be universally used. And so, we still should think about (and hopefully improve) the current state. @aepfli I think one challenge with I guess the question is, do we expect a lot of users today to actually rely on the behavior that different branches of the flag can evaluate to different types? Would anyone actually want a flag that can be either WDYT? |
I also started the second issue about the config validation behavior - #1487 |
No, we don't want users to be able to have different types in the same flag configuration. I'm in favor of making this consistent. If we add the type to the schema, we can perform more sophisticated type checks during validation (and in the JSON schema itself). We could then treat this as a user opting into a more strict type-checking behavior. Perhaps we could start by updating the flagd schema to include this new property. We may be able to leverage some of the work @anghelflorinm did in the cli schema. Any concerns with what I outlined above? @toddbaert @aepfli @lukas-reining @cupofcat |
@cupofcat has been working on flagd and flagd providers: - open-feature/go-sdk-contrib#598 - open-feature/flagd#1481 - open-feature/flagd#1487 Signed-off-by: Todd Baert <[email protected]>
No objections to adding the flag type to the schema, but if I'm following the discussion so far, I think we also agree we should "make things consistent" between We should also spec this and add a spec for it to the gherkin: https://github.com/open-feature/flagd-testbed/blob/main/gherkin/flagd-json-evaluator.feature#L117 |
Observed behavior
For targeting rules that can return different types based on the context (which does not conform to schema but is allowed by flagd with just a warning):
ResolveAll
checks whether the type of the evaluated variant matches the type of thedefaultVariant
Resolve<T>
checks whether the type of the evaluated variant matches<T>
(defaultVariant
does not matter)Expected Behavior
I would expect the behavior to be consistent. If
defaultVariant
is used to infer the flag type, thenResolve<T>
methods should also check whether<T>
matches the type ofdefaultVariant
and not the type of the evaluated variant.Steps to reproduce
For the following flag config:
flagd returns the following:
When changing the
defaultVariant
in the config:ResolveAll
responses:The text was updated successfully, but these errors were encountered: