Conversation
…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.
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
The multi-region lookup in
region.tswas case-sensitive, so a hand-edited.envcarryingNAM5passed 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.tswas 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.