Skip to content

TypeError: Cannot read 'use_v2_feature_versioning' of undefined in feature-list-store #6535

@talissoncosta

Description

@talissoncosta

Bug Description

Users encounter a TypeError when editing/toggling features that prevents the operation from completing.

Error: TypeError: Cannot read properties of undefined (reading 'use_v2_feature_versioning')

Sentry Issue: https://flagsmith.sentry.io/issues/7188659117/

Impact

  • 5 events / 5 users in 1 day
  • First seen: 2026-01-14
  • Blocks feature editing operations

Steps to Reproduce

  1. Open Flagsmith in multiple browser tabs with different projects
  2. Navigate between projects in different tabs
  3. On the Features page, click the toggle switch on any feature
  4. Click "Confirm" in the toggle confirmation modal
  5. Error occurs because ProjectStore has cached environments from a different project

Alternative scenario:

  1. Have a browser tab open on the Features page
  2. Let the session remain idle for an extended period
  3. Try to toggle a feature
  4. ProjectStore may be stale or out of sync

Root Cause

In frontend/common/stores/feature-list-store.ts lines 276-278:

const env = ProjectStore.getEnvironment(environmentId)

if (env.use_v2_feature_versioning) {  // env can be undefined

ProjectStore.getEnvironment() returns undefined when the environment isn't found in the cached environments list.

Suggested Fix

Add null check:

const env = ProjectStore.getEnvironment(environmentId)

if (!env) {
  console.error(`Environment ${environmentId} not found in ProjectStore`)
  store.goneABitWest()
  return
}

if (env.use_v2_feature_versioning) {

Files to Modify

  • frontend/common/stores/feature-list-store.ts (lines 276-278)
  • Same pattern may exist in editFeatureStateChangeRequest function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions