Repository navigation
fix(firestore): honor database-scoped resource selectors - #11461
dajiaohuang wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors and improves the Firestore configuration parsing and resource selection logic during deployment. It introduces support for database-scoped resource targets (e.g., deploying only rules or indexes for a specific database) and simplifies the preparation step by centralizing the target selection logic in getFirestoreConfig. Feedback points out an inconsistency in the single-database configuration path, where global and database-scoped resource selections are not merged, unlike in the multi-database path.
| const resources = selection.allDatabases | ||
| ? selection.allResources | ||
| : selection.byName.get(databaseId) || new Set<FirestoreResource>(); |
There was a problem hiding this comment.
In the single database configuration path, the code does not combine global and database-scoped resource selections. If selection.allDatabases is true (e.g., due to a global selector like firestore:rules), it directly uses selection.allResources and completely ignores any database-scoped selectors defined in selection.byName.\n\nThis is inconsistent with the multi-database array path below, which correctly merges both global and database-scoped resource selections for each database. This discrepancy was not caught by the tests because fsConfig.spec.ts only tests the array configuration, and prepare.spec.ts stubs getFirestoreConfig to return an array.
const resources = new Set(selection.allDatabases ? selection.allResources : []);\n for (const r of selection.byName.get(databaseId) || []) {\n resources.add(r);\n }
Fixes #11447.
Database-scoped Firestore selectors now honor the optional resource suffix:
Global firestore:rules and firestore:indexes selectors remain resource-specific. Comma-separated global and database-scoped selectors combine their resource selections.
Validation: