Skip to content

fix(feature-flags): preserve valid org flags when stored flags contain invalid values (#5058) - #5070

Closed
MilindChatrabhuji wants to merge 1 commit into
triggerdotdev:mainfrom
MilindChatrabhuji:fix/merge-org-feature-flags-invalid-5058
Closed

MilindChatrabhuji wants to merge 1 commit into
triggerdotdev:mainfrom
MilindChatrabhuji:fix/merge-org-feature-flags-invalid-5058

Conversation

@MilindChatrabhuji

Copy link
Copy Markdown

Overview

Fixes #5058

Problem

  1. In apps/webapp/app/v3/featureFlags.server.ts, mergeOrgFeatureFlags validated the entire orgFeatureFlags JSON blob at once with validatePartialFeatureFlags(orgFeatureFlags as Record<string, unknown>). If an organization had even one invalid or obsolete stored flag value in Organization.featureFlags (which admin saves intentionally preserve), the whole validation failed and dropped all of the organization's valid flag overrides, falling back entirely to global defaults.
  2. In FeatureFlagsDialog.tsx:
    • unsetFlag(key) deleted only next[key] without clearing derivedFlagsClearedWith(key), leaving derived grace-stamp flags like runOpsMintKindPrev and runOpsMintKindFlippedAt dangling in overrides.
    • Checking "Unlock read-only flags" erroneously unlocked effect === "derived" grace-stamp rows into editable inputs even though they are server-computed.

Solution

  1. In mergeOrgFeatureFlags, read parseStoredOrgFlags(orgFeatureFlags).valid instead of failing the entire object when an invalid flag is present.
  2. In FeatureFlagsDialog.tsx:
    • Clear derivedFlagsClearedWith(key) inside unsetFlag.
    • Keep effect === "derived" flags locked (read-only) even when unlocked is true.
  3. Added unit test in apps/webapp/test/storedOrgFlags.test.ts verifying that valid org feature flag overrides are preserved when an invalid flag is present in stored organization data.

@algora-pbc /claim #5058

@changeset-bot

changeset-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e74cc3a

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

@coderabbitai

coderabbitai Bot commented Oct 26, 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.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @MilindChatrabhuji, 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 26, 2026

@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 +404 to +405
const { valid } = parseStoredOrgFlags(orgFeatureFlags);
return { ...globalFlags, ...valid };

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.

🟡 Customer-facing flag fix lacks release note

When mergeOrgFeatureFlags restores valid overrides, customers regain dashboard features such as Logs access. This server-only fix lacks the required customer-facing release note.

Learn more

The server changes policy requires a .server-changes/ entry for a customer-visible server-only fix. OrganizationsPresenter supplies these merged flags to the dashboard, and the side menu uses them to show customer features. The PR changes only webapp files and does not include that release entry.

Example: An org has hasLogsPageAccess: true alongside an invalid realtimeBackend. After this fix, its users regain the Logs link; the release notes do not mention the change.

Recommended fix: Add a .server-changes/ Markdown file with area: webapp, type: fix, and one user-facing sentence describing the restored org feature access.

Devin Review


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

@@ -1,3 +1,4 @@
import { mergeOrgFeatureFlags } from "~/v3/featureFlags.server";

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.

🔍 Pure merge test imports server configuration

The new mergeOrgFeatureFlags test loads env.server.ts indirectly through its server module. Webapp test guidance favors separating pure functions from environment-bound modules.

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