feat(backend): expose connect-delegation flag on /api/config#2354
Merged
Conversation
Add google.connectDelegatedToSync to the public AppConfig so the browser can learn, before authenticating, whether this deployment delegates Google connections to the sync service (redirect-based begin flow) instead of the legacy in-backend code-exchange. Populated from the global SYNC_CONNECTION_ROUTING switch via getConnectionDelegation(); defaults to false so legacy deployments are byte-compatible. This is the enabling half of the web connect-delegation UX; the web consumer follows in a separate change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…oller Adds a focused controller unit test that primes the sync client + routing so getConnectionDelegation() resolves to "sync", asserting the flag flips to true. Closes a coverage gap where a hardcoded false would have passed the legacy-only route tests. Relies on per-file test-process isolation to build the lazy client singleton non-null. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
Adds
google.connectDelegatedToSyncto the publicAppConfigreturned byGET /api/config, populated from the globalSYNC_CONNECTION_ROUTINGswitch viagetConnectionDelegation().This is the enabling half of web connect delegation (S38). The browser currently has no way to learn whether a deployment delegates Google connections to the sync service. Because the routing switch is a deployment-level posture (not per-user), the public, already-early-fetched
/api/configis the least-invasive signal — as opposed to the session-authed, per-user/api/user/metadata.The web consumer (fork the connect UX to the redirect flow when this is true) follows in a separate PR. Legacy stays the default; the field defaults to
false, so legacy deployments are byte-compatible.How it's fail-safe
getConnectionDelegation()already fails safe to"legacy"unless an operator selected"sync"and a sync client is configured..default(false), so a web client parsing an older backend response (field absent) reads it asfalse→ legacy. No coordination window where the web breaks.Testing
bun packages/scripts/src/testing/test-mongo-env.ts backend -- './packages/backend/src/config/config.route.test.ts'→ 3 pass.bun run type-check: zero new errors vs.origin/main(verified by set-difference against the pre-existing local baseline)../node_modules/.bin/biome checkclean on changed files.Manual Testing Steps
GET /api/configon a default deployment →google.connectDelegatedToSync: false.SYNC_CONNECTION_ROUTING=sync+SYNC_SERVICE_URLset →true.🤖 Generated with Claude Code
Note
Low Risk
Additive public config field defaulting to false; no auth or connection behavior changes, only surfacing existing routing state.
Overview
GET /api/confignow includesgoogle.connectDelegatedToSync, set when the deployment’s global sync connection routing resolves to the sync service (redirect-based connect) rather than legacy in-backend code exchange.The field is added to
AppConfigSchemawithz.boolean().default(false)so older responses without it still read as legacy.ConfigController.getderives the value from existinggetConnectionDelegation()logic (same fail-safe as auth: sync only when routing is sync and a sync client exists).Tests assert
falseon legacy/default deployments and route expectations, plus a unit test thattruewhen sync routing and client config are set.Reviewed by Cursor Bugbot for commit 35cdb96. Bugbot is set up for automated code reviews on this repo. Configure here.