-
Notifications
You must be signed in to change notification settings - Fork 957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"firebase init" loads Firestore security rules from non-default database #7981
Comments
I dug into the code a bit today, and it seems that this is the code that is handling this flow.
That
And the
I'm not an expert here, but in none of this code there is any consideration for the current database or even the fact that a project can have multiple databases, so I suspect it just returned whatever ruleset was last deployed to the project (rather than to the current database). @aemelyanovff Can you confirm this hypothesis, by deploying another set of rules to the default database in your terminal tab and checking if you then indeed get those rules in the second tab? If that is indeed the problem, the code here needs to be updated to handle the fact that there can be multiple Firestore databases in a project and that each of those has their own history of rulesets. |
No, I always get rules from the non-default database... |
Hey @aemelyanovff, apologies for the issue this has caused and thanks for the detailed report. I'm able to reproduce this, let me raise this to our engineering team so they can take a look. |
[REQUIRED] Environment info
firebase-tools: 13.26.0
Platform: macOS
[REQUIRED] Test case
When there are two Firestore databases in one Firebase project,
firebase init
loads security rules from the non-default database. Expected: load rules from the default database.[REQUIRED] Steps to reproduce
Prerequisite - setup project with different rules in different databases
Take a Firebase project with enabled Firestore and enabled billing. Mine is called
test-non-default-rules
.firebase init firestore --project test-non-default-rules
.firebase --project test-non-default-rules firestore:databases:create non-default --location=nam5
cp firestore.rules firestore-non-default.rules
cp firestore.indexes.json firestore-indexes-non-default.indexes.json
firestore.rules
andfirestore-non-default.rules
different. E.g.firestore.rules
:firestore-non-default.rules
:firebase.json
to include the second database:firebase --project test-non-default-rules deploy --only firestore
Run firebase init again
In a different folder:
firebase init firestore --project test-non-default-rules
.cat firestore.rules
[REQUIRED] Expected behavior
Expect to see rules for the default database.
It'd be even better if there was a way to choose the database, but if there isn't then it should use the default one.
[REQUIRED] Actual behavior
I see rules for the non-default database:
firebase init firestore --project test-non-default-rules --debug
:The text was updated successfully, but these errors were encountered: