Skip to content

fix(firestore-bigquery-export): stop using DATABASE_REGION as the function region - #3066

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

cabljac merged 4 commits into
kitsfrom
fix/kits-fbe-function-region

Conversation

@cabljac

@cabljac cabljac commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

The kit passed DATABASE_REGION as the region option on all three functions, and that select offers the Firestore multi-regions eur3/nam5/nam7, which are not Cloud Run regions, so a multi-region database could not deploy at all.

The #2974 claim that kits build function location in checks out in firebase-tools 15.28.2: an endpoint that declares no region is resolved by resolveDefaultRegionsForBuild (lib/deploy/functions/prepare.js) - the already-deployed region wins, else a trigger-derived default, else us-central1; FIREBASE_FUNCTIONS_DEFAULT_REGION overrides the default (lib/api.js:71). For this kit the trigger-derived path (firestore.getDefaultRegion, FIRESTORE_DUAL_REGION_TO_REGION_MAPPING) cannot fire today: resolution runs on the unresolved build where database is still the CEL string {{ params.DATABASE }}, the lookup throws and is swallowed at debug level, so on a first deploy every function lands in us-central1. The trigger's Eventarc location is pinned to the database independently (lib/deploy/functions/services/firestore.js, ensureFirestoreTriggerRegion).

So this drops the region option and removes DATABASE_REGION and ExportConfig.location outright; nothing else consumed them. A new tests/index.test.ts pins (repro-first) that no exported function sets a region and the trigger still binds database; the built module's discovery manifest was verified locally to emit no region. No live multi-region deploy was attempted. firestore-send-email shares this conflation (its config.ts region: params.databaseRegion) and is left for its own fix.

Fixes #3017

…ction region

DATABASE_REGION offers Firestore locations, including the multi-regions
eur3/nam5/nam7, which are not Cloud Run regions; a function deployed with
region set to one of them cannot deploy at all. The Firebase CLI already
resolves a deploy region for functions that declare none (the already
deployed region, else the database's mapped region for the Firestore
trigger, else us-central1) and pins the trigger's Eventarc location to
the database via the database option, so the parameter had no remaining
consumer: drop the region option and remove DATABASE_REGION and
ExportConfig.location.

Fixes #3017

@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 removes the DATABASE_REGION parameter and the ExportConfig.location property from the firestore-bigquery-export kit. This change prevents deployment failures caused by mapping Firestore multi-region locations (such as eur3, nam5, or nam7) to Cloud Run regions. Instead, the Firebase CLI will automatically resolve the deploy region for each function and pin the Firestore trigger to the database's own region. The documentation, configuration logic, and tests have been updated accordingly, and a new test suite has been added to verify that no exported functions explicitly set a region. There are no review comments, so I have no additional feedback to provide.

cabljac added a commit that referenced this pull request Sep 2, 2026
…3083)

Two CI fixes found via #3066's failing run. The emulator step failed on
every kit with a test:emulator script: firebase-tools 15 requires Java
21+ and the runner's default JAVA_HOME is 17 - the step now points
JAVA_HOME at the preinstalled 21. And the changed-kit detection diffed
against the event's base.sha, which goes stale when the base branch
advances after the PR's last push, pulling base-side kits into the
matrix (that is how counter and chatbot failed #3066's run); detection
now three-dot diffs against the live base ref's merge-base. YAML
validated; the detection command dry-run locally. Like its predecessors,
the workflow only fully proves itself on the next kit PR.
cabljac added a commit that referenced this pull request Sep 2, 2026
Follow-up to #3083, which traded one detection bug for a worse one: the
three-dot diff has no reachable merge base on the depth-1 merge-ref
checkout, and the git failure inside command substitution silently
produced an empty matrix - observed live on #3066's rerun, where all kit
testing was skipped while the job reported green. Two-dot against the
freshly fetched live base ref is exact for a merge-ref checkout (the
merge ref is built on the live tip), and the diff now runs as its own
step line so a git failure fails the job instead of skipping every kit.
YAML validated; the command dry-run locally against origin/kits.
@cabljac
cabljac merged commit c86b1af into kits Sep 2, 2026
11 checks passed
@cabljac
cabljac deleted the fix/kits-fbe-function-region branch September 2, 2026 08:10
cabljac added a commit that referenced this pull request Sep 2, 2026
…ccess and onCompletion (#3071)

The kit README's Events section claimed the function publishes
`onStart`, `onError`, `onSuccess`, and `onCompletion`. The code
publishes `onStart` and `onError` only: `src/handlers.ts` calls
`recordStartEvent` and `recordErrorEvent`, and nothing calls
`recordSuccessEvent` or `recordCompletionEvent`. The extension emitted
`onSuccess` from its `syncBigQuery` task queue handler, which the kit
deliberately removed, and the README's differences section already
documents that. So the README was the wrong side; this corrects the
Events section to list `onStart` and `onError` and point at the
differences entry. Re-adding `onSuccess` emission (parity with the
extension) is a separate decision, not attempted here.

Doc-only change, so no tests. Note #3066 also edits this README; its
hunks (config table, provisioning, region sections) do not overlap this
one.

Fixes #3018
cabljac added a commit that referenced this pull request Sep 2, 2026
…with a multi-region mapping (#3101)

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