When my firestore.indexes.json is empty like so:
{
"indexes": [
{
}
]
}
I'm getting an error on firebase deploy
Error: An unexpected error has occurred.
The content of my firebase-debug.log contains:
[debug] [2017-10-05T23:13:59.475Z] TypeError: Cannot read property 'length' of undefined
at Object.hash (/Users/rootux/.nvm/versions/node/v8.1.2/lib/node_modules/firebase-tools/lib/firestore/indexes.js:158:35)
I would expect a better error message or just accepting of this empty file
Hmm, we could have a better error message here but your indexes file isn't empty since you have one empty object in there. I'd consider this to be empty:
{
"indexes": []
}
@rootux fix merged, this will have a much more obvious error message in the next release.
After upgrading firebase-tools from 5.1.1 -> 6.2.0, I got a similar error:
[2018-12-21T02:09:26.730Z] TypeError: Cannot read property 'collectionId' of undefined
at FirestoreIndexes.upgradeOldSpec (/home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/firestore/indexes.js:307:29)
at FirestoreIndexes.<anonymous> (/home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/firestore/indexes.js:23:31)
at Generator.next (<anonymous>)
at /home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/firestore/indexes.js:7:71
at new Promise (<anonymous>)
at __awaiter (/home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/firestore/indexes.js:3:12)
at FirestoreIndexes.deploy (/home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/firestore/indexes.js:22:16)
at _deployIndexes (/home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/deploy/firestore/deploy.js:30:10)
at module.exports (/home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/deploy/firestore/deploy.js:39:48)
at _chain (/home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/deploy/index.js:22:40)
My firestore.indexes.json (good for [email protected]) is:
{
"indexes": []
}
This seems to be caused by changing the schema of firestore.indexes.json.
How do I fix this?
Could you please show me the correct empty JSON compatible for new firebase-tools?
Well this is my fault and I can fix it first thing tomorrow. In the
meantime if you remove the entry for Firestore indexes in your
firebase.json file I think that will fix it.
On Thu, Dec 20, 2018, 7:00 PM Kazuma Ebina notifications@github.com wrote:
After upgrading firebase-tools from 5.1.1 -> 6.2.0, I got a similar error:
[2018-12-21T02:09:26.730Z] TypeError: Cannot read property 'collectionId' of undefined
at FirestoreIndexes.upgradeOldSpec (/home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/firestore/indexes.js:307:29)
at FirestoreIndexes.(/home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/firestore/indexes.js:23:31)
at Generator.next ()
at /home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/firestore/indexes.js:7:71
at new Promise ()
at __awaiter (/home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/firestore/indexes.js:3:12)
at FirestoreIndexes.deploy (/home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/firestore/indexes.js:22:16)
at _deployIndexes (/home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/deploy/firestore/deploy.js:30:10)
at module.exports (/home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/deploy/firestore/deploy.js:39:48)
at _chain (/home/vsts/.npm/_npx/23791/lib/node_modules/firebase-tools/lib/deploy/index.js:22:40)My firestore.indexes.json (good for [email protected]) is:
{
"indexes": []
}This seems to be caused by changing the schema of firestore.indexes.json.
How do I fix this?
Could you please show me the correct empty JSON compatible for new
firebase-tools?—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebase-tools/issues/495#issuecomment-449225153,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AIEw6ukv_124m2j_A-Jr9Qu-MHAXCZwWks5u7E67gaJpZM4Pv07T
.
Had the same issue with empty indexes.json
This worked thanks.
"remove the entry for Firestore indexes in your firebase.json file I think that will fix it."
In your firebase.json file you probably have a section like this:
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
}
Change it to this
"firestore": {
"rules": "firestore.rules"
}
That will prevent the index deploy from happening at all.
Just hit this issue, reverted to the previous version for now, looking forward to the PR merge @samtstern
Version 6.2.1 is released
Thanks @samtstern, 6.2.1 got further but I'm getting a different error next.
[2018-12-21T22:48:10.753Z] TypeError: Cannot read property 'map' of undefined
at FirestoreIndexes.<anonymous> (/usr/lib/node_modules/firebase-tools/lib/firestore/indexes.js:70:28)
at Generator.next (<anonymous>)
at fulfilled (/usr/lib/node_modules/firebase-tools/lib/firestore/indexes.js:4:58)
at process._tickCallback (internal/process/next_tick.js:68:7)
@vsimon what does your firestore.indexes.json file look like?
{
"indexes": []
}`
@vsimon I can't reproduce:
$ firebase --version
6.2.1
samstern@freewifi:/tmp/tmp.XYhqvivdvk
$ cat firestore.indexes.json
{
"indexes": []
}
samstern@freewifi:/tmp/tmp.XYhqvivdvk
$ firebase --project=fir-dumpster deploy --only firestore:indexes
=== Deploying to 'fir-dumpster'...
i deploying firestore
i firestore: reading indexes from firestore.indexes.json...
i firestore: there are some indexes defined in your project that are not present in your firestore indexes file. Run firebase firestore:indexes and save the result to correct the discrepancy.
✔ firestore: deployed indexes in firestore.indexes.json successfully
✔ Deploy complete!
Weird.
The firebase deploy --debug is using a login:ci token but I don't think that would make a difference. This is more of the output right before the error. I can try just removing the file, but its a bummer that 6.2.1 didn't just work for me.
i firestore: uploading rules firestore.rules...
[2018-12-21T23:14:08.104Z] >>> HTTP REQUEST POST https://firebaserules.googleapis.com/v1/projects/XXXXXXXXXX/rulesets
files=[name=firestore.rules, content=service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow get: if true;
allow write: if false;
}
}
}]
[2018-12-21T23:14:08.105Z] >>> HTTP REQUEST GET https://firestore.googleapis.com/v1beta2/projects/XXXXXXXXXX/databases/(default)/collectionGroups/-/indexes
[2018-12-21T23:14:08.466Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 21 Dec 2018 23:14:08 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="44,43,39,35", accept-ranges=none, connection=close
[2018-12-21T23:14:08.467Z] [rules] created ruleset projects/XXXXXXXXXX/rulesets/1aa1a549-a4d6-4f79-b101-2f81afb930ea
[2018-12-21T23:14:08.474Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 21 Dec 2018 23:14:08 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="44,43,39,35", accept-ranges=none, connection=close
[2018-12-21T23:14:08.475Z] TypeError: Cannot read property 'map' of undefined
at FirestoreIndexes.<anonymous> (/usr/lib/node_modules/firebase-tools/lib/firestore/indexes.js:70:28)
at Generator.next (<anonymous>)
at fulfilled (/usr/lib/node_modules/firebase-tools/lib/firestore/indexes.js:4:58)
at process._tickCallback (internal/process/next_tick.js:68:7)
Error: An unexpected error has occurred.
@vsimon oh ok that explains it, gonna start a new issue
See #1069
Most helpful comment
In your firebase.json file you probably have a section like this:
Change it to this
That will prevent the index deploy from happening at all.