improvement(config): gate feature flags by workspace id - #7191
Merged
Conversation
Add a workspaceIds allowlist clause to the shared AppConfig gate rules and apply it to the credential-groups flag, so the feature can be enabled for a specific workspace without a global rollout.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThe PR adds workspace-scoped AppConfig gates and applies them to credential-group availability while retaining the existing hosted Enterprise-plan requirement.
Confidence Score: 5/5The PR appears safe to merge with no actionable correctness or security defects identified. Workspace targeting is added through the shared gate evaluator, and every updated credential-group production path passes the same canonical workspace ID used to obtain its billing context while preserving the existing Enterprise restriction.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/core/config/appconfig-rules.ts | Adds normalized workspace allowlists and exact workspace-context matching consistently with existing gate clauses. |
| apps/sim/lib/core/config/feature-flags.ts | Exposes workspace targeting through the existing shared feature-flag context and updates credential-group flag documentation. |
| apps/sim/lib/credential-groups/availability.ts | Requires a workspace ID and evaluates credential-group enablement for that workspace before applying the existing billing restriction. |
| apps/sim/lib/credential-groups/application/context.ts | Passes the same workspace ID used to resolve owner billing into credential-group availability checks. |
| apps/sim/lib/credential-groups/enrollments.ts | Evaluates public enrollment availability against the enrollment row’s workspace. |
| apps/sim/lib/credentials/managed-oauth.ts | Evaluates managed credential availability against the credential’s canonical workspace. |
| apps/sim/lib/workspaces/host-context.ts | Computes host-context credential-group availability using the requested workspace and its corresponding owner billing. |
| apps/sim/lib/core/config/appconfig-rules.test.ts | Covers workspace allowlist normalization and matching behavior. |
| apps/sim/lib/core/config/feature-flags.test.ts | Covers allowlisted, non-allowlisted, omitted, and wrong-dimension workspace contexts. |
| apps/sim/lib/credential-groups/availability.test.ts | Verifies that credential-group availability forwards the workspace ID to feature-flag evaluation. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Config[AppConfig credential-groups rule] --> Gate[Feature flag evaluation]
Workspace[Canonical workspace ID] --> Gate
Gate -->|disabled or not allowlisted| Unavailable[Feature unavailable]
Gate -->|enabled or allowlisted| Plan[Hosted Enterprise check]
Billing[Workspace owner billing] --> Plan
Plan -->|Enterprise or self-hosted| Available[Credential groups available]
Plan -->|Hosted non-Enterprise| Unavailable
Reviews (1): Last reviewed commit: "improvement(config): gate feature flags ..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
workspaceIdsallowlist clause to the shared AppConfig gate rules (appconfig-rules.ts), alongside the existingenabled/orgIds/userIds/adminEnabledclauses — normalized and OR-matched the same way, so both thefeature-flagsandblock-visibilitydocuments inherit itworkspaceIdthrough the credential-groups gate:resolveCredentialGroupsAvailability/isCredentialGroupsAvailablenow take{ workspaceId, ownerBilling }and evaluateisFeatureEnabled('credential-groups', { workspaceId })workspaceIdis required, not optional — an omitted id would silently fall through to the global clause instead of the allowlist. All five call sites already had it on hand{ "credential-groups": { "enabled": false, "workspaceIds": ["<workspace-id>"] } }add-feature-flagskill to document the new dimensionNote:
getBlockVisibilitycallers only passuserId/orgId, so aworkspaceIdsrule in theblock-visibilitydocument would never match today — the clause is usable for feature flags.Type of Change
Testing
Unit tests added at all three levels — the new clause in
appconfig-rules(normalize + match), the workspace-scoped rollout infeature-flags, and the availability resolver asserting the flag is evaluated with the workspace id.bun run type-checkclean;lint:check,check:audits(37 audits), andcheck-block-registryall pass.Checklist