Skip to content

fix(db): key the provider cache on the operator's managed grant - #2300

Merged
cevheri merged 2 commits into
mainfrom
fix/provider-cache-managed-grant
Nov 15, 2026
Merged

cevheri merged 2 commits into
mainfrom
fix/provider-cache-managed-grant

Conversation

@cevheri

@cevheri cevheri commented Nov 15, 2026

Copy link
Copy Markdown
Member

The provider cache now keys a connection that carries the operator's managed: true grant apart from the same connection without it.

managed: true decides whom an empty credential signs in as: BigQuery and Firestore sign a keyless seed in with the server's own identity only under that grant.
The cache key did not frame it, so a seed the operator demoted from managed: true to managed: false kept its id, server and empty credential, and went on being served the provider that had signed in as the server, until that provider sat idle for 30 minutes.

Reproduced end to end before the fix, through the real POST /api/db/query, operator loader, resolveConnection, factory and BigQuery provider, with only the session and the Google transport faked.
After the seed file was rewritten with managed: false and GET /api/connections/managed listed it so, the next query still answered 200, sent with the token granted under managed: true, and no new token was requested.

User-visible change:

  • A seed demoted from managed: true to managed: false is refused the server's identity on its next request once the seed file reloads; for BigQuery that is the existing "BigQuery needs a service-account key or an access token in the password field" refusal, with no request sent to Google.

credentialDigest frames managed last and only when it is exactly true, so every connection without the grant keeps its key byte for byte.
A managed connection opens its provider once after the deploy, as after any restart.

docs/BACKLOG.md D85 records the new test as the sixtieth @/lib/auth mock; it spreads the real module and replaces only the session readers.

Test plan

  • bun tests/run-tests.ts tests/api/db/demoted-seed.test.ts: red on main (the second query answered 200 with the server's token), green with the change.
  • bun tests/run-tests.ts tests/unit/lib/db/provider-cache-key.test.ts: new cases red on main, green with the change; the keys of connections without the grant are pinned byte for byte.
  • Every other test file that names providerCacheKey.
  • bun run format, lint, typecheck, knip, chart:check, channels:showcase:check, readme:check, security:check, test, build.
  • bun run test:coverage && bun run coverage:check.
  • bun run build:lib && bun run attw && bun run lib:closure, and the VS Code extension build.

A seed the operator demotes from managed: true to managed: false keeps its
id, server and empty credential, so the provider cache kept serving the
provider that signed in with the server's identity. Reproduced end to end
through POST /api/db/query with BigQuery and a faked Google.

credentialDigest now frames "managed" last, only when managed is exactly
true, so every connection without the grant keeps its key byte for byte.
Split the managed bullet onto its own line in the credentialDigest
docblock, rewrap the public-field list, and put the D85 count line's
second sentence on its own line.
@codecov

codecov Bot commented Nov 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

Copy link
Copy Markdown

@cevheri
cevheri merged commit 22da64a into main Nov 15, 2026
39 checks passed
@cevheri
cevheri deleted the fix/provider-cache-managed-grant branch November 15, 2026 05:59
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.

1 participant