Skip to content

chore: Fix broken override feature on the remote feature flag controller - #9816

Open
Cal-L wants to merge 11 commits into
mainfrom
chore/774-fix-override-feature
Open

chore: Fix broken override feature on the remote feature flag controller#9816
Cal-L wants to merge 11 commits into
mainfrom
chore/774-fix-override-feature

Conversation

@Cal-L

@Cal-L Cal-L commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Explanation

This PR fixes issues related to incorrectly setting and removing flags based on overrides. Prior to this change, the persisted remoteFeatureFlags needed to cleaned prior to effective flag reconstruction, which meant overrides needed to be removed first. This led to broken behavior where flags were completely removed instead of falling back to remote feature flags. We're now leveraging the existing rawRemoteFeatureFlags to reconstruct effective flags. To make this happen, we also removed metametrics ID redacting. For context, there's there's a scenario where QA/PMs/Devs can provide their own metametrics IDs for specific device targeting. That being said, the IDs do not belong to users.

References

Fixes https://consensyssoftware.atlassian.net/browse/MCWP-774

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes feature-flag precedence and persistence semantics (overrides, raw metaMetricsIds in state/logs); incorrect init timing could yield stale flags until fetch.

Overview
Adds RemoteFeatureFlagController.init(), which re-runs version/threshold processing on persisted rawRemoteFeatureFlags (no network fetch) and refreshes effective remoteFeatureFlags, threshold cache, and featureFlagThresholdGroups. Consumers should call init() after restore (e.g. via Wallet.init()).

Override fix: On startup the controller no longer tries to infer the remote layer by stripping override values from persisted effective flags. It keeps a private #processedRemoteFeatureFlags layer and merges defaults → processed remote → local overrides when setting or clearing overrides, so removeFlagOverride restores the real remote value even when it matched the override.

Raw flag storage: redactMetaMetricsIds is removed; rawRemoteFeatureFlags (and debug/state log derivation) retain metaMetricsIds so explicit QA targeting can be re-applied after restart. Processed remoteFeatureFlags still resolve to scalar values without leaking IDs when a match is selected.

Processing refactor: #updateCache and init share #processRemoteFeatureFlags, which now returns the full reconciled threshold cache in one place.

Reviewed by Cursor Bugbot for commit 55e0db6. Bugbot is set up for automated code reviews on this repo. Configure here.

@Cal-L
Cal-L marked this pull request as ready for review August 12, 2026 19:37
@Cal-L
Cal-L requested review from a team as code owners August 12, 2026 19:37
@Cal-L
Cal-L deployed to default-branch August 12, 2026 19:37 — with GitHub Actions Active

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 96f169a. Configure here.

thresholdCache: resolved.thresholdCache,
featureFlagThresholdGroups: resolved.featureFlagThresholdGroups,
};
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Init drops explicit targeting on upgrade

Medium Severity

init reprocesses persisted rawRemoteFeatureFlags, but existing installs still have those raw entries with metaMetricsIds stripped by older builds. Explicit QA targeting then falls through to hash selection and overwrites the previously correct effective value. Because cacheTimestamp is left intact when the client version is unchanged, updateRemoteFeatureFlags can skip a refetch for up to the full cache interval, leaving targeted users on the wrong variant.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 96f169a. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking of leaving this alone for the following reasons:

  • Only affects devs who are still using the metametrics IDs targeting in Launch Darkly
  • Would require persisting another state for triggering a force refetch on this controller version
  • After 24 hrs and calling updateRemoteFeatureFlags will resolve this

Comment thread packages/remote-feature-flag-controller/CHANGELOG.md Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants