Repository navigation
fix(bigquery): sign in through the shared Google auth - #2305
Merged
Merged
Conversation
BigQuery now declares its credential policy in credential-policy.ts and signs in through src/lib/db/auth/google; its own copy, auth.ts, is gone. The move brings the shared parser, ADC chain and token source to BigQuery, with 17 listed behaviour changes: shared refusal sentences, quota project header, lazy guarded token lane, token source closed with the connection, no logged credential path, and the rest in docs/providers/bigquery.md. D294 is closed; D463 to D466 are filed.
Review round 1: pin the job cancel's bearer and quota project after close() and the token deadline signal, list the close-during-refresh sentence change, document serviceusage.services.use for a quota project and the emulator's placeholder key, and correct D464, REL6 and control 3.40.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
17 tasks done
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.



BigQuery now signs in through the shared Google auth in
src/lib/db/auth/google, the module Firestore already uses, and its own copy of the credential and token code (bigquery/auth.ts) is deleted.BigQuery keeps only its policy, declared in the new
bigquery/credential-policy.ts: the three kinds it accepts, its opt-inBIGQUERY_SERVER_CREDENTIALS, its two server-identity sentences (byte-identical), its scope and its project id rule.This closes D294.
What changes
src/lib/db/providers/sql/bigquery/credential-policy.tsis new: the rules object,resolveBigQueryCredential(the process environment and files read at each connect, as before), andbigQueryTokenSourceDeps(), whose transport factory iscreateNodeTransportitself.bigquery/index.tsresolves the credential through the policy; its own browser-empty branch is gone, because the shared gate raises the same sentence.bigquery/transport.tsbuilds its token source withcreateGoogleTokenSource, none underBIGQUERY_EMULATOR_HOSTas before; it sendsx-goog-user-projecton API lanes, checksclosedbefore asking for a token, cancels a job with the bearer of the lane the job last ran on, and closes the token source inclose().tests/unit/db/auth/seam-guard.test.ts: the AUTH6 exception forbigquery/auth.tsis deleted; the list is empty, and the planted proofs plant their own exception.tests/unit/db/bigquery/credentials.test.tsandtoken-source.test.tsare deleted: their mechanism cases live intests/unit/db/auth/google/, their BigQuery cases in the newcredential-policy.test.ts.docs/providers/bigquery.md(Files table, section 3.2 keeps the policy and linksdocs/DB_AUTH.md#google, the logged-path sentence goes, every change below is listed),docs/providers/firestore.md(unpinned mechanism prose of 4.2 and 4.4 becomes a link),docs/DB_AUTH.md(lazy lanes, quota header, blank variables, empty AUTH6 list),docs/SECURITY.mdcontrol 3.40 and its id inscripts/security-check.mjs.docs/BACKLOG.md: D294 deleted; D463 (bearer lane pool in BigQuery, Firestore and Snowflake), D464 (BigQuery API lanes withoutrefusesLinkLocalandrefusesUpgrade), D465 (isServiceAccountKeykeeps CR and LF), D466 (BigQuery error mapping quotes Google's text with no secret forms) filed; REL6 re-measured.bin/lib/launcher-utils.mjsandtests/live/bigquery-evidence.tsfollow the move.User-visible changes
Everything else keeps today's behaviour, including both server-identity sentences, "Google token request failed: " for a reason without a credential form, "The BigQuery connection is closed" for a call after
close(), the scope, the emulator path and the agent leg.credential-policy.test.ts"1:", integration "a credential that does not parse"credential-policy.test.ts"2:", integration "empty client_email"credential-policy.test.ts"3:"kidfromprivate_key_idcredential-policy.test.ts"4:", integration "kid"quota_project_idis checked with BigQuery's project rule and sent asx-goog-user-projecton API and cancel requests, so that project needsserviceusage.services.usefor the user (bigquery.md 3.3)credential-policy.test.ts"5:",transport.test.ts"5:", integration "quota project"credential-policy.test.ts"6:"credential-policy.test.ts"7:"GOOGLE_APPLICATION_CREDENTIALSandHOMEcount as unsetcredential-policy.test.ts"8:"credential-policy.test.ts"9:"%APPDATA%credential-policy.test.ts"10:"GCE_METADATA_HOSTis validated ([::1]:8080kept,http://xrefused)credential-policy.test.ts"11:"expires_in0 or below is one hour; an empty token is refused; a reason is cut to 300 characters; anullbody is refused cleanlytransport.test.ts"12:"typeis not echoedcredential-policy.test.ts"13:"refusesLinkLocalandrefusesUpgrade; a pasted token builds nonetransport.test.ts"14:", integration "token lane"close()closes the token source and aborts a refresh in flight; a later call keeps "The BigQuery connection is closed"; a job cancel uses the bearer and quota project of the job's lane, afterclose()too. A call waiting on a refresh thatclose()aborts now fails with "The request was cancelled", or "The Google token source is closed" while an assertion is being signed, where it failed with "The connection was closed, so the request did not complete"transport.test.ts"15:", and the unchanged close and abort testscredential-policy.test.ts"a named file that cannot be read"transport.test.ts"17:"Changes 7 and 9 remove silent fallbacks: a setup that relied on a bare token in an ADC file, or on an unreadable gcloud file falling through to the metadata server, now sees a refusal that names the cause.
The Turbopack warning count of
bun run buildon this branch is 6, none of them a BigQuery file (REL6 updated).Test plan
The new integration cases and the new transport cases fail on the base branch and pass here.
The full gate set,
test:coveragewithcoverage:check,build:lib,attw,lib:closureand the VS Code build run in CI.