Skip to content

fix(firestore-bigquery-export): normalize DATABASE_REGION before the region lookup - #3153

Open
cabljac wants to merge 1 commit into
kitsfrom
fix/kits-fbe-region-case
Open

cabljac wants to merge 1 commit into
kitsfrom
fix/kits-fbe-region-case

Conversation

@cabljac

@cabljac cabljac commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

The multi-region lookup in region.ts was case-sensitive, so a hand-edited .env carrying NAM5 passed through untouched and reproduced the deploy failure the mapping exists to prevent. The value is now trimmed and lowercased before the lookup, regional values come out lowercased too, and a whitespace-only value counts as unset.

This is the same change #3102 made to firestore-send-email, whose region.ts was copied from this kit. Both kits now behave identically.

Tests cover NAM5, Eur3, nam7, a mixed-case regional value, and a whitespace-only value. Unit suite passes locally (105 tests). No live deploy run.

…region lookup

Lowercase and trim the value so a hand-edited `.env` carrying `NAM5` maps to
`us-central1` instead of passing through and failing the deploy. Keeps the
kit in step with firestore-send-email's region mapping.

@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 firestoreLocationToFunctionRegion utility to normalize the location parameter by trimming surrounding whitespace and converting it to lowercase before performing region lookups. This ensures case-insensitive matching and prevents deployment failures due to hand-edited configuration files containing whitespace or mixed-case region names. Additionally, corresponding unit tests have been added to verify these normalization behaviors, and the changelog has been updated. I have no feedback to provide as the changes are well-implemented and thoroughly tested.

@IzaakGough IzaakGough 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.

Change looks good. Verified against both callers of firestoreLocationToFunctionRegion (src/index.ts and src/tasks.ts), and region.ts plus tests/region.test.ts are now identical to the firestore-send-email versions. Tests pass locally.

One docs follow-up left inline.

location: string | undefined
): string | undefined {
if (!location) {
const normalized = location?.trim().toLowerCase();

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.

Could the README pick up the same note? README.md still tells users to set FUNCTION_REGION to their DATABASE_REGION value for a manual enqueue, and the DATABASE_REGION places the functions section says regional locations are used as-is, so neither mentions the lowercasing. Someone with DATABASE_REGION=Europe-West2 who follows it literally sets FUNCTION_REGION=Europe-West2, but the function deployed to europe-west2, so gcloud functions describe --region Europe-West2 and taskQueue("locations/Europe-West2/functions/kit-default-initBigQuerySync") both point at a region that does not exist.

firestore-send-email/README.md already carries "The value is matched case-insensitively"; the same sentence here would finish the parity. Not blocking.

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.

2 participants