-
Notifications
You must be signed in to change notification settings - Fork 468
Open
Labels
bugSomething isn't workingSomething isn't workingfront-endIssue related to the React Front End DashboardIssue related to the React Front End Dashboard
Description
Summary
Users encounter a crash when editing multivariate (MV) feature flags. The error TypeError: Cannot read properties of undefined (reading 'multivariate_options') occurs when originalFlag exists in the store but lacks the multivariate_options property.
Sentry Issue
- FLAGSMITH-FRONTEND-48Y - 47 events, 15 users affected
- First seen: 7/10/2025
- Last seen: 1/19/2026
Root Cause
In frontend/common/stores/feature-list-store.ts, the editFeatureMv function assumes originalFlag.multivariate_options always exists:
// Line 223 - crashes if originalFlag.multivariate_options is undefined
const originalMV = v.id
? originalFlag.multivariate_options.find((m) => m.id === v.id)
: null
// Line 246 - also crashes
const deletedMv = originalFlag.multivariate_options.filter(
(v) => !flag.multivariate_options.find((x) => v.id === x.id),
)Git history:
- Bug introduced in
4aee3b3f4(May 30, 2022) - PR Chores/remove mv segment flag #1164 - Partial fix attempted in
9aa67c390(June 9, 2022) but null checks were not added - Likely became more frequent after RTK Query migration in 2025
Proposed Fix
Add defensive null checks:
// Line 221-224
Promise.all(
(flag.multivariate_options || []).map((v, i) => {
const originalMV = v.id && originalFlag?.multivariate_options
? originalFlag.multivariate_options.find((m) => m.id === v.id)
: null
// ...
}),
)
// Line 246
const deletedMv = (originalFlag?.multivariate_options || []).filter(
(v) => !flag.multivariate_options.find((x) => v.id === x.id),
)Acceptance Criteria
- Add null checks for
originalFlag.multivariate_optionsinfeature-list-store.ts - Editing MV feature flags no longer crashes when store data is incomplete
- E2E tests pass
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfront-endIssue related to the React Front End DashboardIssue related to the React Front End Dashboard