Skip to content

Conversation

@talissoncosta
Copy link
Contributor

Summary

This PR fixes issues with multivariate (MV) variation weights when creating change requests and segment overrides.

Bugs Fixed

  1. Segment override MV weights sent as 0% - When creating change requests with segment overrides, the multivariate weights were being sent as 0% instead of the actual user-entered values. This was caused by using default_percentage_allocation (project-level default) instead of percentage_allocation (override weight).

  2. Diff view not showing all variations - The change request diff view wasn't showing all project variations, only those that existed in the old/new state arrays. This made it hard to see newly added variations.

  3. React state mutations - Direct array mutations in SegmentOverrides.js prevented React from detecting state changes, causing UI inconsistencies.

Changes Made

File Changes
feature-list-store.ts Use buildSegmentOverrideMvValues to build MV state values with correct override weights
SegmentOverrides.js Fix state mutations (use map instead of direct mutation), filter unsaved variations, use updateVariationWeight
diff-utils.ts Add projectMultivariateOptions param to show all variations, detect newly added variations for 0% -> X% diff
DiffFeature.tsx Pass projectFlag.multivariate_options to diff functions
DiffSegmentOverrides.tsx Pass projectFlag through to DiffVariations
FeatureListProvider.js Use mapMvOptionsToStateValues for change request creation
utils.tsx Add buildSegmentOverrideMvValues, updateVariationWeight, mapMvOptionsToStateValues utilities
CreateFlag.js Use environmentVariations instead of identityVariations for change requests

Known Limitations / Out of Scope

  • New variation diff shows no change when already deployed: When you add a new variation to a project (e.g., "d" with 7% default weight), it gets immediately deployed to all environments with the default weight. If you then create a change request without modifying that weight, the diff correctly shows no change (7% -> 7%). This is expected behavior since project-level variations are global, while change requests track environment-level weight changes.

Test plan

  • Create a feature with multivariate variations
  • Add a segment override with custom MV weights
  • Create a change request - verify MV weights are preserved (not reset to 0%)
  • View change request diff - verify all variations are shown with correct old/new weights
  • For new segment overrides, verify diff shows 0% -> X% for variations

🤖 Generated with Claude Code

@talissoncosta talissoncosta requested a review from a team as a code owner January 10, 2026 00:24
@talissoncosta talissoncosta requested review from kyle-ssg and removed request for a team January 10, 2026 00:24
@vercel
Copy link

vercel bot commented Jan 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview, Comment Jan 12, 2026 11:53am
flagsmith-frontend-staging Ready Ready Preview, Comment Jan 12, 2026 11:53am
1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Ignored Ignored Preview Jan 12, 2026 11:53am

@github-actions github-actions bot added front-end Issue related to the React Front End Dashboard fix labels Jan 10, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 10, 2026

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-6509 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-6509 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-6509 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-6509 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-6509 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-6509 Finished ✅ Results

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

multivariate_feature_option: mvOption.id,
percentage_allocation: weight,
}
})
Copy link

Choose a reason for hiding this comment

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

Unused parameter causes incorrect feature state value IDs

Medium Severity

The mapMvOptionsToStateValues function accepts _existingMvFeatureStateValues as a second parameter but never uses it. The function returns MultivariateFeatureStateValue objects with id set to mvOption.id (the multivariate option ID). However, MultivariateFeatureStateValue.id should be the feature state value ID, not the option ID. The _existingMvFeatureStateValues parameter appears intended to look up correct feature state value IDs but is ignored. This could cause API issues when updating existing feature states, as the incorrect ID might prevent proper matching of existing records. The similar function buildSegmentOverrideMvValues correctly omits the id field entirely.

Fix in Cursor Fix in Web

talissoncosta and others added 8 commits January 11, 2026 22:56
…StateValues

New multivariate variations that haven't been saved to the project yet
don't have IDs. When creating change requests, these variations cannot
be referenced until they are saved. This fix filters out variations
without IDs to prevent invalid data being sent to the API.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
The Scheduling link was using 'change-requests-link' ID which is also
used by the Change Requests link. This caused e2e tests to click on
the wrong element. Renamed to 'scheduled-changes-link' for uniqueness.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Added data-test='js-feature-change-requests' attribute to the
ChangeRequestsSetting component to enable e2e tests to reliably
detect and interact with the feature change requests toggle.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add comprehensive e2e tests for change requests with multivariate
features:
- TEST 1: Create change request with MV weight changes
- TEST 2: Verify values are NOT applied before CR is published
- TEST 3: Verify CR diff shows correct weight values
- TEST 4: Create segment override with MV weights via change request
- TEST 5: Verify segment override CR contains correct values

Tests cover both feature state and segment override change requests,
ensuring MV weights are correctly stored and displayed in the diff.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…Values

The function now handles both MultivariateOption (from project flag)
and MultivariateFeatureStateValue (from segment overrides) types.

Previously, segment override MV options were filtered out because they
have 'multivariate_feature_option' property instead of 'id', causing
MV weights to not be stored in change requests for segment overrides.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add projectFlag prop to DiffSegmentOverrides and DiffSegmentOverride
components to display variation values in the diff view. Without this,
variation values were shown as empty in segment override diffs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Verify that MV weight values (60%, 30%, 10%) are displayed in the
change request diff view for segment overrides.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Fix operator precedence issue where || had higher precedence than concat,
causing the array to not be properly concatenated. Wrap the left operand
in parentheses to ensure correct evaluation order.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants