Repository navigation
fix(firestore): do not create a missing database on deploy --dry-run - #11509
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the Firestore preparation logic to prevent 'firebase deploy --dry-run' from creating a missing Firestore database, instead reporting where the database would be created. It also handles 403 errors gracefully during dry runs when checking rules on projects without an existing database. The review feedback recommends extracting the default location 'nam5' into a top-level constant and removing a redundant inline comment that narrates self-evident code, aligning with the repository's style guide.
|
Thanks for the contribution, this looks good! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11509 +/- ##
=======================================
Coverage ? 60.72%
=======================================
Files ? 864
Lines ? 50587
Branches ? 10168
=======================================
Hits ? 30721
Misses ? 18778
Partials ? 1088 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Fixes #11491.
firebase deploy --dry-runonly skips the deploy and release phases; prepare still runs. Firestore's prepare step callscreateDatabase(), so a dry run against a project where the configured database does not exist created it for real, innam5whenlocationis not set.With this change, on a dry run:
nam5default becausefirebase.jsonsets none.:testendpoint returns 403 until the first database exists (the reason Fixing firestore deploy on fresh projects #9220 creates the database before compiling). In that case only, the dry run logs a warning that the rules could not be checked instead of failing. A 403 when the database exists, and any compilation error, still fail the dry run.A normal deploy behaves as before.
Two things I noticed in the same function and left out to keep this focused (happy to send follow-ups):
firebase.json,createDatabase()only checks the first one.getDatabase()is swallowed.Scenarios Tested
Unit tests in
src/deploy/firestore/prepare.spec.ts(newdry runblock, 7 tests):createDatabasenot called, warning names the database andnam5 (the default ...), rules still compiledlocation: "eur3": warning nameseur3nam5as beforeWithout the fix in
prepare.ts, the first, second and fourth fail. Firestore prepare/deploy/release specs,src/deploy/index.spec.tsandsrc/rulesDeploy.spec.ts: 78 passing. ESLint and Prettier clean on the changed files.Sample Commands
firebase deploy --dry-run(or--only firestore) with afirestore.databaseinfirebase.jsonthat does not exist in the project.