Skip to content

fix(firestore): honor database-scoped resource selectors - #11461

Open
dajiaohuang wants to merge 1 commit into
firebase:mainfrom
dajiaohuang:codex/firestore-database-scoped-resources
Open

dajiaohuang wants to merge 1 commit into
firebase:mainfrom
dajiaohuang:codex/firestore-database-scoped-resources

Conversation

@dajiaohuang

Copy link
Copy Markdown

Fixes #11447.

Database-scoped Firestore selectors now honor the optional resource suffix:

  • firestore:<databaseId|target>:rules prepares and deploys only rules for that database.
  • firestore:<databaseId|target>:indexes prepares and deploys only indexes for that database.
  • firestore:<databaseId|target> continues to select both resources.
  • Unsupported resource suffixes fail instead of being silently ignored.

Global firestore:rules and firestore:indexes selectors remain resource-specific. Comma-separated global and database-scoped selectors combine their resource selections.

Validation:

  • Focused Firestore specs: 14 passing.
  • ESLint on the four changed files: 0 errors; 44 warnings.
  • The project TypeScript compile reports seven diagnostics in unchanged files (dataconnect-sql-shell.ts, frameworks/astro/utils.ts, gcp/cloudsql/connect.ts, and logger.ts); none reference the changed files. Full npm test was not run.

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

Comment thread src/firestore/fsConfig.ts
Comment on lines +107 to +109
const resources = selection.allDatabases
? selection.allResources
: selection.byName.get(databaseId) || new Set<FirestoreResource>();

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.

medium

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      }

This branch has not been deployed

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

Multi-DB: --only firestore:<databaseId> also deploys indexes, and firestore:<databaseId>:rules ignores the suffix

1 participant