fix(bigquery): preserve project on view updates - #3121
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the initializeLatestView function to pass the BigQuery project ID (bqProjectId) when initializing or updating the latest view, ensuring the correct project is referenced instead of defaulting to the function's project ID. A corresponding unit test has been added to verify this behavior. There are no review comments, so no further feedback is provided.
IzaakGough
left a comment
There was a problem hiding this comment.
Fix looks right. The update path was the last place still falling back to process.env.PROJECT_ID, and since bq.projectId is set to config.bqProjectId || process.env.PROJECT_ID it can't be worse than before. I checked out the head and confirmed the new test fails without the added line.
One thing to flag: firestore-bigquery-change-tracker is published separately and is still on 2.0.4, which is what functions/package.json resolves via ^2.0.4, so deployed instances won't pick this up until a new version goes out. Happy for that to be a follow-up if releases are batched here, just wanted to make sure it isn't missed.
|
Is there a larger problem for kits here that all process.env.PROJECT_ID uses won't work? There were a bunch of them: https://github.com/search?q=repo%3Afirebase%2Fextensions+process.env.PROJECT_ID&type=code I haven't tested a deployed function but from documentation I assume GCLOUD_PROJECT and GOOGLE_CLOUD_PROJECT will be populated alternatives. |
…view updates, release 2.2.1 (#3137) 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 --------- Co-authored-by: Corie Watson <watson.corie@gmail.com>
Changes
Testing
npm run compilejest --runInBand src/__tests__/bigquery/materializedViews/initializeLatestView.test.tsCloses #3120