Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kits/firestore-bigquery-export/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- fix: `DATABASE_REGION` is matched case-insensitively and with surrounding whitespace ignored, so a hand-edited `.env` carrying `NAM5` deploys to `us-central1` instead of failing the deploy
- fix: `USE_NEW_SNAPSHOT_QUERY_SYNTAX` and `EXCLUDE_OLD_DATA` take the extension's `yes` / `no` values again, so a config exported from the extension works unchanged. `WILDCARD_IDS` is unchanged: the extension already used `true` / `false` there.
- feat: reinstate the extension's Cloud Tasks write buffer. A failed inline BigQuery write now enqueues onto a new `syncBigQuery` task queue (5 attempts, 60s minimum backoff, throttled by the restored `MAX_DISPATCHES_PER_SECOND` param, default 100) instead of replaying the Firestore event through Eventarc redelivery for up to 24 hours; `MAX_ENQUEUE_ATTEMPTS` (default 3) is also back. The `onSuccess` event returns with the queue handler. Two behavior changes against earlier release candidates: a row that exhausts the queue is dropped unless `BACKUP_COLLECTION` is set (extension parity - the tracker backs the row up on every terminal insert failure, so configure a backup collection), and deleting or moving the functions can leave the Cloud Tasks queue behind. A failed enqueue is logged at error level, published as an `onError` event, and dropped, as in the extension; the trigger no longer declares `retry: true`, so nothing is redelivered through Eventarc. Export the new `syncBigQuery` function from your codebase entry, and deploy with Firebase CLI 15.28.0+ so the trigger can address its own queue (`FIREBASE_KIT_INSTANCE_ID`); requires firebase-admin 14.2.0+.
- fix: restore explicit function placement from `DATABASE_REGION`, now with the Firestore-location-to-Cloud-Run-region mapping. The `DATABASE_REGION` parameter is back and all three functions deploy to the region derived from it: regional locations pass through unchanged, and the multi-region locations map to a Cloud Run region (`nam5`/`nam7` to `us-central1`, `eur3` to `europe-west1`) instead of failing the deploy. With the parameter unset the functions still declare no region and the CLI falls back as before (`us-central1` by default, `FIREBASE_FUNCTIONS_DEFAULT_REGION` to override). Placement requires firebase-tools >= 15.28.0 (older CLIs do not load `.env` at discovery and keep the fallback). If your `.env` already carries `DATABASE_REGION` from an extension migration, upgrading to this version moves the functions to the mapped region on your next deploy, which deletes and recreates them.
Expand Down
11 changes: 7 additions & 4 deletions kits/firestore-bigquery-export/src/region.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ const MULTI_REGION_TO_FUNCTION_REGION: Record<string, string> = {

/**
* Maps a Firestore database location to the Cloud Run region the functions
* should deploy to. Regional locations pass through unchanged; an unset or
* empty location returns `undefined`, meaning the functions declare no region.
* should deploy to. The lookup is case-insensitive and ignores surrounding
* whitespace, as the CLI's own region handling is. Regional locations pass
* through lowercased; an unset or blank location returns `undefined`, meaning
* the functions declare no region.
*/
export function firestoreLocationToFunctionRegion(
location: string | undefined
): string | undefined {
if (!location) {
const normalized = location?.trim().toLowerCase();
if (!normalized) {
return undefined;
}
return MULTI_REGION_TO_FUNCTION_REGION[location] ?? location;
return MULTI_REGION_TO_FUNCTION_REGION[normalized] ?? normalized;
}
18 changes: 18 additions & 0 deletions kits/firestore-bigquery-export/tests/region.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,22 @@ describe("firestoreLocationToFunctionRegion", () => {
test("returns undefined for an empty location", () => {
expect(firestoreLocationToFunctionRegion("")).toBeUndefined();
});

test("returns undefined for a whitespace-only location", () => {
expect(firestoreLocationToFunctionRegion(" ")).toBeUndefined();
});

test.each([
["NAM5", "us-central1"],
["Eur3", "europe-west1"],
[" nam7 ", "us-central1"],
])("normalizes %s before the multi-region lookup", (location, region) => {
expect(firestoreLocationToFunctionRegion(location)).toBe(region);
});

test("lowercases and trims a regional location", () => {
expect(firestoreLocationToFunctionRegion(" Europe-West2 ")).toBe(
"europe-west2"
);
});
});
Loading