`init firestore` on an empty project throws `Error fetching Firestore indexes`
[REQUIRED] Environment info
firebase-tools:
v11.14.1
Platform:
all
[REQUIRED] Test case
See https://github.com/firebase/firebase-tools/issues/1988#issuecomment-1272398432
[REQUIRED] Steps to reproduce
https://github.com/firebase/firebase-tools/issues/1988#issuecomment-1272398432
[REQUIRED] Expected behavior
Succeed
[REQUIRED] Actual behavior
Error fetching Firestore indexes
Assigning to Bryan to triage.
So here's the error I'm actually seeing when I try this.
- Created a new empty project via console.
- Associated it with a billing account (Blaze plan)
- Attempted to init firestore, was told it was not enabled, so I went to the console and enabled it.
- Re-attempted to init firestore and got the error when fetching indexes.
[2022-10-10T21:50:47.626Z] >>> [apiv2][query] GET https://firestore.googleapis.com/v1/projects/xxxxxxxx/databases/(default)/collectionGroups/-/indexes [none]
[2022-10-10T21:50:47.627Z] >>> [apiv2][query] GET https://firestore.googleapis.com/v1/projects/xxxxxxxx/databases/(default)/collectionGroups/-/fields?filter=indexConfig.usesAncestorConfig=false [none]
[2022-10-10T21:50:47.876Z] <<< [apiv2][status] GET https://firestore.googleapis.com/v1/projects/xxxxxxxx/databases/(default)/collectionGroups/-/indexes 400
[2022-10-10T21:50:47.876Z] <<< [apiv2][body] GET https://firestore.googleapis.com/v1/projects/xxxxxxxx/databases/(default)/collectionGroups/-/indexes {"error":{"code":400,"message":"This operation is not available for Cloud Firestore projects in Datastore Mode.","status":"FAILED_PRECONDITION"}}
[2022-10-10T21:50:47.878Z] FirebaseError: HTTP Error: 400, This operation is not available for Cloud Firestore projects in Datastore Mode.
at responseToError (/.../Repositories/firebase-tools/lib/responseToError.js:49:12)
at RetryOperation._fn (/.../Repositories/firebase-tools/lib/apiv2.js:288:77)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Great. I keep testing and debugging, and it suddenly it told me "403: You need to enable the API" (it already was - I did nothing). The Cloud console also told me that that Firestore was in native mode, not Datastore mode.
I keep trying, now that I know it's unstable. The next time I try, API works as expected and writes my indexes.
So, unfortunately, the answer here is to be patient. The API can take (in my case almost 10) minutes to fully enable through all the systems. But once it's enabled, I don't see an issue pulling down indexes.
I experienced the same error. Solution was to simply add data in the web console to firestore, then it immediatley worked with firebase init firestore.
I have this issue as of November 12th, 2022.
- Firestore console says the database is already in Native Mode.
- The firestore database for this project was created since 2018 and is a production database with millions of reads.
- I can't get the indexes, no matter if I try firebase init firestore or the indexes command itself.
- Tried adding data to the database from web firestore console (a new collection) but it did nothing (data is being added every second by production users, anyway).
5/10 times I get "Error: Error fetching Firestore indexes" 5/10 times I get "Error: It looks like you haven't used Cloud Firestore in this project before."
Second one is impossible since, like I said, it's a production database with millions of document reads. Firestore API is enabled, the database itself has millions of documents. Firebase tools is updated.
Edit: Just got: Error: Failed to get Firebase project corntech-restaurant. Please make sure the project exists and your account has permission to access it. Right after it made me firebase login --reauth
Can't simply drop it and create another database given it's already a production project. What can I do?
Maybe we could update the error message to include advice to "be patient".
This issue was described in https://github.com/firebase/firebase-tools/issues/1988 and now in https://github.com/firebase/firebase-tools/issues/5099
I have since uninstalled firebase and am deploying to a different service. I can't help you debug this but you do need to understand the problem before you close the issues.
It seems like there may be an issue with hot potatoes and contributors.