Repository navigation
fix(webapp): preserve valid org flags when invalid flag is stored (#5058) #5086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import { | |
| ORG_LOCKED_FLAGS, | ||
| ORG_LOCKED_FLAG_EFFECT, | ||
| isUnchangedInvalidFlag, | ||
| mergeOrgFeatureFlags, | ||
| parseStoredOrgFlags, | ||
| validatePartialFeatureFlags, | ||
| } from "~/v3/featureFlags"; | ||
|
|
@@ -94,3 +95,46 @@ describe("isUnchangedInvalidFlag", () => { | |
| expect(isUnchangedInvalidFlag(KEY, { [KEY]: { x: null } }, {})).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe("mergeOrgFeatureFlags", () => { | ||
| const globalFlags = { | ||
| [FEATURE_FLAG.hasLogsPageAccess]: false, | ||
| [FEATURE_FLAG.hasQueryAccess]: false, | ||
| }; | ||
|
|
||
| it("merges valid org overrides on top of global flags", () => { | ||
| const result = mergeOrgFeatureFlags(globalFlags, { | ||
| [FEATURE_FLAG.hasLogsPageAccess]: true, | ||
| }); | ||
| expect(result).toEqual({ | ||
| [FEATURE_FLAG.hasLogsPageAccess]: true, | ||
| [FEATURE_FLAG.hasQueryAccess]: false, | ||
| }); | ||
| }); | ||
|
|
||
| it("preserves valid org flags when an invalid flag is present in stored org flags", () => { | ||
| const result = mergeOrgFeatureFlags(globalFlags, { | ||
| [FEATURE_FLAG.hasLogsPageAccess]: true, | ||
| [FEATURE_FLAG.snapshotStoreMode]: "invalid-mode", | ||
| }); | ||
|
Comment on lines
+115
to
+119
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 New flag tests lack regression comments The new Learn moreRepository testing guidance requires a one-line Example: The test with Recommended fix: Add the required Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| expect(result).toEqual({ | ||
| [FEATURE_FLAG.hasLogsPageAccess]: true, | ||
| [FEATURE_FLAG.hasQueryAccess]: false, | ||
| }); | ||
| }); | ||
|
|
||
| it("ignores unknown keys in stored org flags when merging", () => { | ||
| const result = mergeOrgFeatureFlags(globalFlags, { | ||
| [FEATURE_FLAG.hasLogsPageAccess]: true, | ||
| unknownKey: "should-be-ignored", | ||
| }); | ||
| expect(result).toEqual({ | ||
| [FEATURE_FLAG.hasLogsPageAccess]: true, | ||
| [FEATURE_FLAG.hasQueryAccess]: false, | ||
| }); | ||
| }); | ||
|
|
||
| it.each([null, undefined, "", 123, []])("returns global flags unchanged for %j", (raw) => { | ||
| expect(mergeOrgFeatureFlags(globalFlags, raw)).toEqual(globalFlags); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Flag fix missing server release note
When stored flags contain an invalid entry,
mergeOrgFeatureFlagsnow restores valid overrides and changes users' navigation. The required server release note is absent.Learn more
The server-only release-note rule requires a
.server-changes/entry for a user-visible webapp bug fix. OrganizationsPresenter passes these flags to the side menu, where valid overrides reveal or hide navigation. No release-note file was added with this change.Example: An org has
hasLogsPageAccess: trueand an invalidsnapshotStoreMode. Its Logs navigation returns after this fix; users notice that change.Recommended fix: Add a
.server-changes/file witharea: webapp,type: fix, and a one-line description of restored organization features.Was this helpful? React with 👍 or 👎 to provide feedback.