Skip to content

fix(firestore-bigquery-change-tracker): preserve BigQuery project on view updates, release 2.2.1 - #3137

Merged
cabljac merged 3 commits into
nextfrom
fix/tracker-2.2.1-view-project
Sep 7, 2026
Merged

fix(firestore-bigquery-change-tracker): preserve BigQuery project on view updates, release 2.2.1#3137
cabljac merged 3 commits into
nextfrom
fix/tracker-2.2.1-view-project

Conversation

@cabljac

@cabljac cabljac commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Cherry-pick of da21982 from #3121 (Corie's fix, approved by Izaak) onto next, plus the 2.2.1 version bump and changelog entry. #3121 targets kits, but the tracker is published from next, so the fix never reached npm from there.

The bug: initializeLatestView builds the snapshot query for an existing _raw_latest view without bqProjectId, so buildLatestSnapshotViewQuery falls back to process.env.PROJECT_ID. That variable is only set for extensions. On a kit the view query became undefined.<dataset>.<table> and the initBigQuerySync task failed in afterFirstDeploy. The create path already passed the project. The fix passes bq.projectId on the update path too, matching the create path.

Tests: the materializedViews suites pass locally (20 tests), including the new one that sets process.env.PROJECT_ID to a decoy and asserts the query uses the BigQuery project. Not verified against a live redeploy.

After merge, dispatch npm_publish_bq_scripts.yml for 2.2.1, then regenerate the kit shrinkwrap in the stack so the rc pins it.

Fixes #3120

@cabljac
cabljac requested a review from a team as a code owner September 7, 2026 17:05

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the firestore-bigquery-change-tracker package to version 2.2.1. It fixes an issue where updating an existing _raw_latest view failed on plain Cloud Functions because the snapshot query builder dropped the bqProjectId parameter, causing it to fall back to process.env.PROJECT_ID (which is undefined outside of extensions). The fix explicitly passes bqProjectId: bq.projectId when initializing the latest view, and a corresponding unit test has been added to verify this behavior. There are no review comments, so I have no feedback to provide.

@cabljac
cabljac merged commit 0a7d599 into next Sep 7, 2026
18 checks passed
@cabljac
cabljac deleted the fix/tracker-2.2.1-view-project branch September 7, 2026 17:17
cabljac added a commit that referenced this pull request Sep 8, 2026
First layer of the Cloud Tasks write buffer stack. Bumps firebase-admin
from ^13.6.0 to ^14.2.0 and the change tracker from ^2.1.0 to ^2.2.1,
regenerates the shrinkwrap, and adds one override; no source changes.
The admin bump also moves `@google-cloud/firestore` from 7.11.6 to
8.7.1, a major on the client the tracker's backup writes go through.

The next layers enqueue onto a task queue by bare function name.
firebase-admin 14.2.0 resolves the deployed `kit-<instance id>-` prefix
itself from `FIREBASE_KIT_INSTANCE_ID`, which the Firebase CLI sets on
every deployed kit function from 15.28.0, so the kit does not have to
reconstruct the prefix.

Tracker 2.2.0 (#3133, #3134) is the first release that runs on
firebase-admin 14: earlier versions pinned admin 13 and used the
namespaced API, so npm nested a second admin copy under the tracker with
no default app and every backup write failed. 2.2.1 (#3137) adds the
view-update project fix from #3120. The shrinkwrap now holds a single
`firebase-admin@14.3.0`, verified by resolving
`firebase-admin/firestore` from the tracker's directory and calling
`getFirestore` after the kit's `initializeApp`. The kit pins
`firebase-functions ^7.3.3-rc.0`, which no stable range in the tracker
can match, so a root `overrides` entry pins the tracker's
firebase-functions to the kit's own; the shrinkwrap holds a single
`firebase-functions@7.3.3-rc.0` as well, so tracker log lines keep the
kit's trace context. That single-copy guarantee reaches consumers
through the published shrinkwrap and holds for npm installs only: npm
ignores `overrides` from a non-root package, and pnpm and yarn ignore a
dependency's `npm-shrinkwrap.json`, so they resolve the tracker's
`^6.3.2 || ^7.3.0` to a second firebase-functions copy.

62 unit tests and `tsc -b` pass on this layer; 89 on the top of the
stack. The top of the stack was also deployed to a test project with
Firebase CLI 15.29.0: `afterFirstDeploy` provisioned the dataset,
changelog table, and view; create, update, and delete events landed in
the changelog; a redeploy exercised the update-view path with the
project preserved; and with the changelog table removed, the trigger
enqueued onto `syncBigQuery`, the tracker wrote backup documents through
admin 14 / firestore 8.7.1, and the queue drained without duplicate rows
once the table was re-provisioned.

Part of #3031.
@cabljac cabljac mentioned this pull request Sep 8, 2026
69 tasks
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.

🐛 [@firebase-function-kits/firestore-bigquery-export] afterFirstDeploy taskqueue initialization failed from missing PROJECT_ID

2 participants