Skip to content

fix(identities): multivariate override editor hides the identity's override value - #8279

Open
bardock-2393 wants to merge 1 commit into
Flagsmith:mainfrom
bardock-2393:fix/mv-override-editor-hides-value
Open

fix(identities): multivariate override editor hides the identity's override value#8279
bardock-2393 wants to merge 1 commit into
Flagsmith:mainfrom
bardock-2393:fix/mv-override-editor-hides-value

Conversation

@bardock-2393

Copy link
Copy Markdown
Contributor

When a flag with an existing identity override is later made multivariate, the Edit User Feature modal stops showing what that identity is actually being served. The editor offers only the environment's control value and each variation as radios, so an override holding anything else has nowhere to appear — the control row reads as selected and the identity looks like it is on the environment default. The override is intact and the SDK keeps serving it, but saving the modal replaced it with the control value, so the value could be lost by simply opening and saving.

Rather than hiding it, the editor now shows the override's own value as a read-only, already-selected row alongside the variations, and warns that the value is not one of them so the user can move the identity onto a variation deliberately. Saving keeps the value unless the user picks the control or a variation instead.

Changes

  • The Edit User Feature modal shows an identity's override value even when it is not one of the flag's variations.
  • A warning explains that the value is not a variation, and recommends changing it.
  • Saving the modal no longer replaces such an override with the environment's control value.
  • Tests covering when an override counts as unrepresentable by the variation radios.

Closes #8271

Review effort: 2/5

How did you test this code?

Manually, end to end, against a local API and dashboard, following the reproduction steps in the issue: a flag with control value ENV_DEFAULT, an identity override of MY_OVERRIDE, then a variation VARIANT_A added to make the flag multivariate.

  • Opening Edit User Feature for that identity shows the warning, MY_OVERRIDE selected and read-only, ENV_DEFAULT and VARIANT_A unselected. On main the same modal shows ENV_DEFAULT selected and MY_OVERRIDE nowhere.
  • Pressing Update Feature without changing the selection leaves the stored value as MY_OVERRIDE (confirmed directly in the database). On main this is where the override was replaced with the control value.

Automated: the rule deciding whether an override is representable by the variation radios is unit tested in common/utils/__tests__/multivariate.test.ts, including the plan-unchanged case, an identity assigned a variation, a partially weighted override, and null/undefined/empty edge cases. npm run test:unit passes in full (402 tests), npm run lint reports nothing on the changed files, and npm run typecheck produces an identical error set to main for them.

A note on behaviour

The same guard applies when a multivariate identity override's stored value has drifted from the environment's control value for any other reason — for example the environment control being edited after the override was made. Previously a save silently re-synced the identity onto the new control value, changing what that identity is served; now the value is shown, flagged, and left alone until the user chooses. That seemed the safer default given the issue is about a value disappearing, but say the word if you would rather keep re-syncing in that case.

…erride value

The editor for a multivariate flag only renders the environment's control
value and each variation as radios, so an identity override holding any other
value has nowhere to appear. The control row reads as selected and the
identity looks like it is on the environment default, even though the SDK
still serves the override. Saving the modal then replaced the override with
the control value.

Show such a value as a read-only, selected row alongside the variations, warn
that it is not one of them, and keep it on save unless the user picks the
control or a variation instead.
@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

@bardock-2393 is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds hasUnmatchedIdentityOverride with tests for value and allocation cases. The feature value tab detects unmatched identity overrides and passes them to VariationOptions. The UI displays the unmatched value in a disabled editor and updates control selection. Identity saves preserve unmatched override values instead of always applying the environment control value.

Estimated code review effort: 3 (Moderate) | ~20 minutes

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the front-end Issue related to the React Front End Dashboard label Aug 12, 2026
@bardock-2393
bardock-2393 marked this pull request as ready for review August 12, 2026 20:33
@bardock-2393
bardock-2393 requested a review from a team as a code owner August 12, 2026 20:33
@bardock-2393
bardock-2393 requested review from talissoncosta and removed request for a team August 12, 2026 20:33

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0a36622b-b132-4506-adde-3ddfe7686830

📥 Commits

Reviewing files that changed from the base of the PR and between 6c88198 and 66eeee4.

📒 Files selected for processing (5)
  • frontend/common/utils/__tests__/multivariate.test.ts
  • frontend/common/utils/multivariate.ts
  • frontend/web/components/modals/create-feature/index.tsx
  • frontend/web/components/modals/create-feature/tabs/FeatureValueTab.tsx
  • frontend/web/components/mv/VariationOptions.tsx

Comment on lines +20 to +23
}: {
controlValue: FlagsmithValue
overrideValue: FlagsmithValue
variationOverrides: { percentage_allocation: number }[] | null | undefined

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Extract the variation override union into a named type.

variationOverrides uses an inline union type. Define a named type and use it in the parameter object.

Proposed fix
+type VariationOverrides =
+  | { percentage_allocation: number }[]
+  | null
+  | undefined
+
 export const hasUnmatchedIdentityOverride = ({
   controlValue,
   overrideValue,
   variationOverrides,
 }: {
   controlValue: FlagsmithValue
   overrideValue: FlagsmithValue
-  variationOverrides: { percentage_allocation: number }[] | null | undefined
+  variationOverrides: VariationOverrides
 }): boolean =>

As per coding guidelines, frontend/**/*.{ts,tsx} must extract inline union types into named types.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
}: {
controlValue: FlagsmithValue
overrideValue: FlagsmithValue
variationOverrides: { percentage_allocation: number }[] | null | undefined
type VariationOverrides =
| { percentage_allocation: number }[]
| null
| undefined
export const hasUnmatchedIdentityOverride = ({
controlValue,
overrideValue,
variationOverrides,
}: {
controlValue: FlagsmithValue
overrideValue: FlagsmithValue
variationOverrides: VariationOverrides
}): boolean =>

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multivariate override editor hides the identity's override value (shows the flag's control value instead)

1 participant