Skip to content

fix(flipt): Fix FliptProvider to honor server default variant when match is false#1776

Open
Openroads wants to merge 2 commits intoopen-feature:mainfrom
Openroads:fix/flipt-default-variant-on-nomatch
Open

fix(flipt): Fix FliptProvider to honor server default variant when match is false#1776
Openroads wants to merge 2 commits intoopen-feature:mainfrom
Openroads:fix/flipt-default-variant-on-nomatch

Conversation

@Openroads
Copy link
Copy Markdown

This PR

Fixes Flipt variant evaluation fallback behavior so that the provider honors Flipt’s server-side default variant even when match=false. Previously, FliptProvider#evaluateVariant returned the OpenFeature SDK defaultValue whenever response.isMatch() was false, which caused the server-provided default variant (variantKey) to be ignored.

  • uses the SDK defaultValue only when match=false and variantKey is null/empty
  • preserves the server-returned variant (and value derived from the current variant logic) when variantKey is present, even if match=false
    adds a unit test covering the match=false + variantKey (server default) scenario

Notes

The new test uses a mocked /evaluate/v1/variant response with match=false and a non-empty variantKey to validate the behavior.

How to test

Run and verify the new test passes:
getStringVariantEvaluation_usesServerDefaultVariantWhenNoMatch

@Openroads Openroads requested a review from a team as a code owner April 17, 2026 12:43
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Flipt provider to support server-provided default variants. Previously, if a targeting match was not found, the provider would immediately return the SDK's default value. The logic now checks for a server-provided variant key even when a match is false, allowing the server's default configuration to take precedence. A review comment identifies that the evaluation reason should be updated to 'DEFAULT' in these cases to comply with the OpenFeature specification, as the current implementation would incorrectly report 'TARGETING_MATCH'.

Dariusz Szyszlak added 2 commits April 18, 2026 21:05
…ere is no match

Signed-off-by: Dariusz Szyszlak <dariusz.szyszlak@gmail.com>
…o match but default variant is returned from the server

Signed-off-by: Dariusz Szyszlak <dariusz.szyszlak@gmail.com>
@Openroads Openroads force-pushed the fix/flipt-default-variant-on-nomatch branch from 282b001 to 2f67900 Compare April 18, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants