Skip to content

fix(firestore-bigquery-export): place functions from DATABASE_REGION with a multi-region mapping - #3101

Merged
cabljac merged 2 commits into
kitsfrom
fix/kits-fbe-database-region-mapping
Sep 2, 2026
Merged

cabljac merged 2 commits into
kitsfrom
fix/kits-fbe-database-region-mapping

Conversation

@cabljac

@cabljac cabljac commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

This partially reverts #3066, by agreement with the firebase-tools team. #3066 removed the DATABASE_REGION param because its raw value was used as the function region, which hard-failed deploys for multi-region databases (#3017). But the CLI's region inference the kit fell back to is unreliable for param-declared databases: region resolution runs before param substitution and silently defaults to us-central1 (firebase/firebase-tools#11020). Since the extension-to-kit migration exports DATABASE_REGION into the user's .env, the decision is to keep using it, with the mapping that makes it safe where the pre-#3066 code failed.

The restored param now places all three functions: Firestore multi-region locations map to a Cloud Run region (nam5/nam7 to us-central1, eur3 to europe-west1, mirroring the CLI's own FIRESTORE_DUAL_REGION_TO_REGION_MAPPING); regional locations pass through; unset keeps today's no-region behavior. The region is read from process.env at module load, which requires firebase-tools >= 15.28.0 (firebase/firebase-tools#10936) to be present during discovery; on older CLIs it degrades to the no-region fallback rather than failing. Tests pin all mapping cases and the unset case, and breaking the mapping fails them. No live multi-region deploy was run this time; #3066's no-region behavior was live-verified on nam5.

…with a multi-region mapping

Restore the DATABASE_REGION param and use it to place all three functions,
mapping Firestore multi-region locations to Cloud Run regions (nam5/nam7 ->
us-central1, eur3 -> europe-west1) so multi-region databases no longer fail
the deploy. Regional locations pass through unchanged; with the param unset
the functions declare no region and the CLI fallback behavior is kept.

Partially reverts #3066. The CLI's own region inference is unreliable for
param-declared databases (firebase/firebase-tools#11020), and the
extension-to-kit migration exports DATABASE_REGION into the user's .env, so
the value is present for migrating users.

@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 restores explicit function placement based on the DATABASE_REGION parameter, mapping Firestore multi-region locations to valid Cloud Run regions (such as mapping nam5 to us-central1) to prevent deployment failures. The feedback suggests adding an 'Unset' option with a default empty string to the DATABASE_REGION configuration to allow users to bypass interactive CLI prompts, trimming the input region string to handle accidental whitespaces, and clearing mock history between test runs to prevent fragile indexing in assertions.

Comment thread kits/firestore-bigquery-export/src/config.ts
Comment thread kits/firestore-bigquery-export/src/region.ts
Comment thread kits/firestore-bigquery-export/tests/index.test.ts
@cabljac
cabljac merged commit dd7e4f2 into kits Sep 2, 2026
16 checks passed
@cabljac
cabljac deleted the fix/kits-fbe-database-region-mapping branch September 2, 2026 19:29
cabljac added a commit that referenced this pull request Sep 8, 2026
…for function placement (#3102)

Fixes #3069. The kit passed the raw DATABASE_REGION value as the
function's region, and the param's select offers the Firestore
multi-regions eur3/nam5/nam7, which are not Cloud Run regions, so
multi-region deploys hard-failed.

The issue proposed dropping the region option (the #3066 pattern). This
PR deliberately deviates: by agreement with the firebase-tools team,
DATABASE_REGION stays and is mapped instead, because the CLI's own
inference is unreliable for param-declared databases
(firebase/firebase-tools#11020) and the extension-to-kit migration
exports DATABASE_REGION into the user's .env. Multi-regions map to a
region inside them (nam5/nam7 to us-central1, eur3 to europe-west1,
mirroring the CLI's FIRESTORE_DUAL_REGION_TO_REGION_MAPPING); regional
locations pass through; unset or empty means no region option and the
CLI fallback. #3101 is the sibling fix for firestore-bigquery-export.

Tests pin all mapping cases plus the unset case; breaking the mapping
fails them. Caveats: no live multi-region deploy was run for this kit,
and the module-load process.env read needs firebase-tools >= 15.28.0
during discovery (older CLIs degrade to the no-region fallback). The
approved #3089 also touches src/config.ts; this change edits only
envDeployOptions at the end of the file, so overlap is limited to a
trivial CHANGELOG conflict.
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.

1 participant