Skip to content

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

Open
joehan wants to merge 2 commits into
mainfrom
joehanley/fix-pr-11461
Open

joehan wants to merge 2 commits into
mainfrom
joehanley/fix-pr-11461

Conversation

@joehan

@joehan joehan commented Nov 10, 2026

Copy link
Copy Markdown
Member

Description

Fixes #11447. Supersedes #11461 (preserving @dajiaohuang's original commit and addressing all review feedback).

Database-scoped Firestore deploy selectors now honor the optional resource suffix (:rules or :indexes) across both single-database and multi-database firebase.json configurations:

  • firestore:<databaseId|target>:rules prepares and deploys only rules for that database or target.
  • firestore:<databaseId|target>:indexes prepares and deploys only indexes for that database or target.
  • firestore:<databaseId|target> continues to select both resources for that database or target.
  • Global firestore:rules and firestore:indexes selectors remain resource-specific and merge cleanly with comma-separated database-scoped selectors in both single-database and multi-database configurations.
  • Unsupported resource suffixes and non-matching database targets in both single-database and multi-database configurations fail with actionable FirebaseError remediation messages and { exit: 1 }.

Scenarios Tested

  • Unit tests in src/firestore/fsConfig.spec.ts covering:
    • Multi-database configurations (global selectors, database-scoped :rules / :indexes, merged global + database-scoped selectors, and unmatched target errors with exit: 1).
    • Target aliases mapped via .firebaserc (firestore:<target>:rules, firestore:<target>:indexes, and merged global + target-scoped selectors).
    • Single-database configurations (default (default) and named single-DB configs, global + database-scoped merging, and unmatched target errors with exit: 1).
    • Invalid deploy target syntax rejection with remediation guidance and exit: 1.
  • Unit tests in src/deploy/firestore/prepare.spec.ts verifying database-scoped rules-only and indexes-only deploy preparation (160 passing across src/firestore/*.spec.ts and src/deploy/firestore/*.spec.ts).
  • npm run build, npm run test:compile, ESLint, and Prettier checks.

Sample Commands

firebase deploy --only firestore:db2
firebase deploy --only firestore:db2:rules
firebase deploy --only firestore:db2:indexes
firebase deploy --only firestore:rules,firestore:db2:indexes

@joehan
joehan requested a review from aalej November 10, 2026 19:11

@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 fixes an issue where deploying specific Firestore resources using '--only firestore::rules' or 'firestore::indexes' would deploy both rules and indexes instead of only the requested resource. The logic in 'src/firestore/fsConfig.ts' was refactored to parse and filter the selected Firestore configurations more robustly, and the preparation step in 'src/deploy/firestore/prepare.ts' was simplified to rely on these parsed configurations. Comprehensive unit tests were added to verify various deployment target scenarios, including multi-database setups, target aliases, single-database configurations, and invalid targets. I have no feedback to provide as the changes are well-implemented and thoroughly tested.

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

LGTM! Tested the filters and they work as expected

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

2 participants