Visitar URL original
fix(webapp): preserve valid org flags when invalid flag is stored (#5058) by ghazy2001 · Pull Request #5086 · triggerdotdev/trigger.dev · GitHub
Skip to content

fix(webapp): preserve valid org flags when invalid flag is stored (#5058) - #5086

Closed
ghazy2001 wants to merge 1 commit into
triggerdotdev:mainfrom
ghazy2001:fix/merge-org-feature-flags-keep-valid-5058
Closed

ghazy2001 wants to merge 1 commit into
triggerdotdev:mainfrom
ghazy2001:fix/merge-org-feature-flags-keep-valid-5058

Conversation

@ghazy2001

Copy link
Copy Markdown

Fixes #5058

Background & Issue

When mergeOrgFeatureFlags merged stored organization flags onto global flags, it invoked validatePartialFeatureFlags(orgFeatureFlags). Because validatePartialFeatureFlags validates the object as a whole, a single invalid or deprecated flag in an organization's stored flags caused the entire parse to fail. Consequently, all valid org flag overrides were dropped and reverted to global defaults.

Solution

  • Updated mergeOrgFeatureFlags to use parseStoredOrgFlags(orgFeatureFlags).valid, which parses stored flags key-by-key and preserves all valid catalog flags even if an invalid or unknown flag is present.
  • Placed mergeOrgFeatureFlags in apps/webapp/app/v3/featureFlags.ts alongside parseStoredOrgFlags, and re-exported it from apps/webapp/app/v3/featureFlags.server.ts for backward compatibility.
  • Added unit tests in apps/webapp/test/storedOrgFlags.test.ts verifying that valid org flags are retained when invalid flags are present, unknown keys are ignored, and non-object inputs are safely handled.

@changeset-bot

changeset-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ac1d812

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Hi @ghazy2001, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this Oct 29, 2026
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

Devin Review

Comment on lines +397 to +398
const validOrgFlags = orgFeatureFlags ? parseStoredOrgFlags(orgFeatureFlags).valid : {};
return { ...globalFlags, ...validOrgFlags };

Copy link
Copy Markdown
Contributor

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, mergeOrgFeatureFlags now 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: true and an invalid snapshotStoreMode. Its Logs navigation returns after this fix; users notice that change.

Recommended fix: Add a .server-changes/ file with area: webapp, type: fix, and a one-line description of restored organization features.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +115 to +119
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",
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 New flag tests lack regression comments

The new mergeOrgFeatureFlags tests omit the required // Catches: regression comments. Their intended regressions remain undocumented for future reviewers.

Learn more

Repository testing guidance requires a one-line // Catches: <bug> comment naming the specific regression each new unit test protects against. The added merge tests contain no such comments, including the test that protects the invalid-stored-flag regression.

Example: The test with hasLogsPageAccess: true and snapshotStoreMode: "invalid-mode" protects against one invalid stored flag suppressing a valid override, but its regression is not named.

Recommended fix: Add the required // Catches: comments to retained tests and remove any added cases that cannot identify a distinct regression.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

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.

bug: mergeOrgFeatureFlags drops all valid org feature flags when one stored flag is invalid

1 participant