flipt icon indicating copy to clipboard operation
flipt copied to clipboard

[Bug]: getting string flag via open feature sdk

Open Cirilus opened this issue 8 months ago • 4 comments

Bug Description

There is an error when trying to get the string value via open feature sdk. If you don't use the segments in the ui and setting only the default route it returns the code of the Default and the open feature returning the default value that in the code but not in the flipt.

Version Info

github.com/open-feature/go-sdk-contrib/providers/flipt v0.1.3

Search

  • [x] I searched for other open and closed issues before opening this

Steps to Reproduce

  1. Create the string ff
  2. Creating the only default value
  3. Trying to get this flag via open feature sdk

Expected Behavior

Returning the default value that in the flipt not in the code.

Additional Context

No response

Cirilus avatar Apr 08 '25 21:04 Cirilus

Hello @Cirilus! I'm here to help you with any bugs, questions, or contributions you might have while you wait for a human maintainer. Looking forward to assisting you!

The issue you're experiencing seems to be related to how the Open Feature SDK handles default values when no segments are defined and only a default route is set in Flipt. In such cases, the SDK might be returning the fallback value specified in the code rather than the default value configured in Flipt.

The Open Feature SDK determines which default value to return by using the fallback value provided in the method call. If an error occurs, such as a JSON exception or a client exception, the SDK logs the error and returns the fallback value specified in the method parameters [1].

To address this issue, you might want to ensure that the configuration in Flipt is correctly set up to reflect the desired default value and verify that the SDK is correctly configured to interact with Flipt. If the problem persists, it might be worth checking for any updates or patches to the SDK that address this behavior.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar Apr 08 '25 21:04 dosubot[bot]

I just skimmed through the code, but I think the problem here, you should return the rpcevaluation.EvaluationReason_MATCH_EVALUATION_REASON here https://github.com/flipt-io/flipt/blob/main/internal/server/evaluation/evaluation.go#L74

Cirilus avatar Apr 08 '25 21:04 Cirilus

or maybe somewhere deeper

Cirilus avatar Apr 09 '25 06:04 Cirilus

Hey @Cirilus thanks for the issue.

I agree there is some inconsistency here but I think its in the OpenFeature implementations, not Flipt server implementation.

Here in the JS OpenFeature provider it looks like we are doing what you expect:

https://github.com/open-feature/js-sdk-contrib/blob/358a04f3f0b8f97765eaf67d8c7000ec2f18bf80/libs/providers/flipt/src/lib/flipt-provider.ts#L172-L186

 if (!variantEvaluation.match && variantEvaluation.reason != 'DEFAULT_EVALUATION_REASON') {
        return {
          value: defaultValue,
          reason: StandardResolutionReasons.DEFAULT,
        };
      }

...

      return {
        value: flagValue,
        reason: StandardResolutionReasons.TARGETING_MATCH,
      };

If Flipt server returns Default reason then we convert it to MATCH for the OpenFeature response and return the value from the Flipt server instead of the one you provided in code. It seems like we need to do the same for the Go SDK as well as check the other open feature SDK providers and make sure the behavior is consistent

markphelps avatar Apr 11 '25 15:04 markphelps