[firestore-bigquery-change-tracker] BigQuery client project override clobbers ADC auto-detection when bqProjectId and PROJECT_ID are both unset
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Start at src/bigquery/index.ts:146 and compare its client initialization with the fallback used at snapshot.ts:68. Trace how bqProjectId, PROJECT_ID, and GCLOUD_PROJECT are selected, then verify that omitted project settings preserve BigQuery ADC detection while explicit settings still select the intended project.
Written by the indexing model from the issue text.
Description
Package: @firebaseextensions/firestore-bigquery-change-tracker, src/bigquery/index.ts:146 on next.
this.bq = new bigquery.BigQuery();
this.bq.projectId = config.bqProjectId || process.env.PROJECT_ID;
new BigQuery() with no projectId leaves the client's internal {{projectId}} placeholder in place, and @google-cloud/common resolves it from Application Default Credentials on the first request. The assignment on line 146 overwrites that placeholder unconditionally. When the caller passes no bqProjectId and process.env.PROJECT_ID is unset, bq.projectId becomes undefined, auto-detection never runs, and every generated query references undefined.<dataset>.<table>.
PROJECT_ID is an extensions-only variable. A plain Cloud Function (gen1 or gen2) never has it. The Firebase CLI sets FIREBASE_CONFIG and GCLOUD_PROJECT only.
Who is affected: any consumer of the tracker that omits bqProjectId and is not an extension. The firestore-bigquery-export kit is not affected, it always passes bqProjectId (kits/firestore-bigquery-export/src/export-config.ts:191 falls back to projectID.value()). #3120 and 2.2.1 fixed the one kit-reachable variant of this (the update-view path dropped bqProjectId).
Suggested fix: only assign when a value exists, and prefer GCLOUD_PROJECT over PROJECT_ID as the env fallback.
const projectId = config.bqProjectId || process.env.PROJECT_ID || process.env.GCLOUD_PROJECT;
this.bq = projectId ? new bigquery.BigQuery({ projectId }) : new bigquery.BigQuery();
snapshot.ts:68 has the same bqProjectId || process.env.PROJECT_ID fallback and should follow the same order. Both initializeLatestView call sites now pass bqProjectId, so that one is defensive only.
Found during the adversarial review of #3137. Related: #2779 proposes a GOOGLE_CLOUD_PROJECT fallback, which the CLI does not set either.
- Dominant language
- TypeScript
- Stars
- 979
- Forks
- 433
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 119
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from firebase/extensions
-
kits
Difficulty 1/5 Under an hour Newbie friendliness 90/100
firebase/extensions#3195 ·
-
extension: firestore-bigquery-export type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
firebase/extensions#3144 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
firebase/extensions#2977 ·
-
type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
firebase/extensions#2972 ·
-
type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
firebase/extensions#2971 ·
All issues in firebase/extensions
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·