refactor: single-source the multi-org (OS_MULTI_ORG_ENABLED) flag resolution#2350
Merged
Merged
Conversation
"Is this deployment multi-org?" was resolved in 10 sites across 8 packages with 3 subtly different inline expressions — including a bare process.env read in the SQL driver that skipped the OS_MULTI_TENANT deprecation warning every other site emits, so the driver could resolve the mode independently of the auth/security layer. Add resolveMultiOrgEnabled() to @objectstack/types (beside readEnvWithDeprecation) as the single source of truth and route all 10 sites through it: - driver-sql isMultiTenantMode() (+ new @objectstack/types dep) - plugin-auth /auth/config features + beforeCreateOrganization guard - objectql registry, runtime app-plugin, plugin-dev - cli serve (x2) + verify, cloud-connection Behaviour unchanged except the SQL driver now also emits the one-shot OS_MULTI_TENANT deprecation warning. Mirrors the resolveAuthzContext single-source pattern in @objectstack/core. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 8 package(s): 38 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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.
Problem
"Is this deployment multi-org / multi-tenant?" was resolved in 10 places across 8 packages with three subtly different inline expressions:
String(readEnvWithDeprecation('OS_MULTI_ORG_ENABLED','OS_MULTI_TENANT') ?? 'false').toLowerCase() !== 'false'env.OS_MULTI_ORG_ENABLED !== undefined ? … : …(redundant explicit check)/auth/configfeatures +beforeCreateOrganizationguardprocess.env.OS_MULTI_ORG_ENABLED ?? process.env.OS_MULTI_TENANTisMultiTenantMode()— skipped theOS_MULTI_TENANTdeprecation warning every other site emitsBecause the SQL driver computed the mode independently of the auth/security layer (and via a different code path), the driver's tenant-audit gate and the rest of the system could in principle disagree about whether tenant isolation is active. This is the kind of divergence single-sourcing eliminates.
Change
resolveMultiOrgEnabled()to@objectstack/types(besidereadEnvWithDeprecation— the natural leaf dependency every consumer already imports) as the single source of truth.@objectstack/driver-sqlgains a direct@objectstack/typesdependency (it previously readprocess.envdirectly).Mirrors the existing
resolveAuthzContextsingle-source pattern in@objectstack/core.Safety
Behaviour is unchanged everywhere except the SQL driver, which now also emits the one-shot "
OS_MULTI_TENANTis deprecated, rename toOS_MULTI_ORG_ENABLED" warning — making it consistent with every other site (an improvement, not a regression). The boolean semantics (raw ?? 'false', case-insensitive!== 'false') are byte-for-byte the canonical expression the 9 other sites already used.Follow-up (not in this PR)
A lint gate forbidding new inline
OS_MULTI_ORG_ENABLED/OS_MULTI_TENANTreads outside the helper (the same shape ascheck:authz-resolver), so the consolidation can't silently drift back.Verification
🤖 Generated with Claude Code