Skip to content

Conversation

@talissoncosta
Copy link
Contributor

@talissoncosta talissoncosta commented Jan 20, 2026

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Closes #6552

Adds defensive null checks for originalFlag.multivariate_options in the editFeatureMv function to prevent crashes when editing multivariate feature flags with incomplete store data.

Root Cause: When originalFlag exists in the store but multivariate_options is undefined, the code crashes with:

TypeError: Cannot read properties of undefined (reading 'multivariate_options')

Fix:

  • Line 222-225: Added originalFlag?.multivariate_options check before accessing .find()
  • Line 247: Added fallback to empty array (originalFlag?.multivariate_options || [])

Sentry Issue: FLAGSMITH-FRONTEND-48Y - 47 events, 15 users affected

How to reproduce

  1. Navigate to a project's Features page
  2. Create or select a feature with multivariate options
  3. Open the feature modal to edit it
  4. The error occurs when the store has the feature but multivariate_options is undefined (race condition or stale data)

Alternative reproduction (simulating the bug):

  1. Open Chrome DevTools → Sources tab
  2. Navigate to a feature with multivariate options
  3. Set a breakpoint in feature-list-store.ts at the editFeatureMv function
  4. Manually set originalFlag.multivariate_options = undefined in the console
  5. Continue execution → observe the crash

After the fix: The code gracefully handles undefined multivariate_options by using optional chaining and fallback to empty array.

How did you test this code?

Fixes #6552

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@talissoncosta talissoncosta requested a review from a team as a code owner January 20, 2026 16:34
@talissoncosta talissoncosta requested review from kyle-ssg and removed request for a team January 20, 2026 16:34
@vercel
Copy link

vercel bot commented Jan 20, 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 20, 2026 4:36pm
flagsmith-frontend-staging Ready Ready Preview, Comment Jan 20, 2026 4:36pm
1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Ignored Ignored Jan 20, 2026 4:36pm

Request Review

@talissoncosta talissoncosta requested review from Zaimwa9 and removed request for kyle-ssg January 20, 2026 16:35
@github-actions github-actions bot added front-end Issue related to the React Front End Dashboard fix labels Jan 20, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2026

Docker builds report

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

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.

Fix: TypeError when editing multivariate feature flags - missing null check on originalFlag.multivariate_options

2 participants