firebase-js-sdk icon indicating copy to clipboard operation
firebase-js-sdk copied to clipboard

"Create index" link not provided (firebase 8.7.1)

Open charles-allen opened this issue 5 years ago • 44 comments

Describe your environment

  • Operating System version: MacOS 11.4 (20F71)
  • Browser version: Node v14.16.0
  • Firebase SDK version: firebase 8.7.1
  • Firebase Product: Firestore

Describe the problem

I wrote a query that requires an index. It errors with this message (which doesn't contain a link to create the index):

  • Expected: link to create index
  • Actual: no link

Screen Shot 2021-07-15 at 13 03 57

Steps to reproduce:

  • Write a query with where/orderBy on multiple fields

Relevant Code:

const query = db.collection('iterations')
  .where('courseCode', '==', code)
  .orderBy('iterationCode', 'desc')
  .limit(1)
  .get()

charles-allen avatar Jul 15 '21 06:07 charles-allen

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Jul 15 '21 06:07 google-oss-bot

It seems that only the Client SDKs are returning an error "FirebaseError: No matching index found" instead of index creation links. The Admin SDK still throws an error with the link. You can try running your query in Firebase Functions emulator and get the link from there. I've posted a similar answer on Stackoverflow.

export const getIndexLink = functions.https.onRequest(async (request, response) => {
    try {
        const snap = const query = db.collection('iterations')
            .where('courseCode', '==', code)
            .orderBy('iterationCode', 'desc')
            .limit(1)
            .get()
        console.log(snap.size)
        response.send( snap.size, "documents matched");
    } catch (error) {
        console.log(error)
        response.send(error.message)
        // Error with index creation link
    }
});

You can try calling this function in a browser and get the index creation link.

DharmarajX24 avatar Jul 15 '21 06:07 DharmarajX24

Hi @charles-allen, thanks for the report. I was able to replicate the issue. Let me bring this matter to the attention of our engineers here and update this thread if I have any information to share.

looptheloop88 avatar Jul 15 '21 11:07 looptheloop88

I guess the even older versions of firebase library aren't providing url image

dreamerchandra avatar Jul 15 '21 17:07 dreamerchandra

We're also seeing similar reports on other platforms. It seems to be a backend issue and currently being tracked internally. For reference, see b/193768583.

looptheloop88 avatar Jul 15 '21 18:07 looptheloop88

We are encountering this too for all required indexes not built. "firebase": "^8.7.1", "firebase-admin": "^9.11.0", "firebase-tools": "^9.16.0",

jbistis avatar Jul 16 '21 17:07 jbistis

any updates?

madisonatamea avatar Jul 17 '21 21:07 madisonatamea

Got the same error, any updates ?

jaimejangg avatar Jul 18 '21 17:07 jaimejangg

Looks like we're going to stick with this problem and create the indexes manually :(

jailsondamasceno avatar Jul 18 '21 18:07 jailsondamasceno

Any updates? It breaks my app completely.

lxieyang avatar Jul 18 '21 21:07 lxieyang

Any updates? It breaks my app completely.

Unless your app is automatically creating missing indexes (which sounds like a questionable design decision), this is not breaking your app.

Just create the index manually in Firebase Console. It's slightly less convenient, but I wouldn't consider this bug to be blocking.

charles-allen avatar Jul 19 '21 02:07 charles-allen

I'm having the same issue and for some reason I can't even create an index manually from the console.

r-ndom-developer avatar Jul 19 '21 04:07 r-ndom-developer

Looks like we're going to stick with this problem and create the indexes manually :(

I mean you can still create those click to create index links from Admin SDK in emulator @jailsondamasceno 👀

DharmarajX24 avatar Jul 19 '21 08:07 DharmarajX24

Hi ,

Any update on this.

FYI If manually create on console it also not working as intended.

Lazy-Developer-here avatar Jul 19 '21 12:07 Lazy-Developer-here

for some reason I can't even create an index manually from the console.

FYI If manually create on console it also not working as intended.

This is not what I'm seeing. I made an index manually using the console and my code now runs fine.

If you're having problems with the console you should open an issue with details, screenshots, etc.

charles-allen avatar Jul 19 '21 17:07 charles-allen

Also having troubles with this. I can create an index via the console but it still does not recognise it once it is built, giving me the same error.

dionkas avatar Jul 19 '21 17:07 dionkas

@dionkas Here, likewise

jailsondamasceno avatar Jul 19 '21 18:07 jailsondamasceno

Same problem...

BluebambooSRL avatar Jul 19 '21 19:07 BluebambooSRL

Same issue and its really costing me a lot of time .... Please fix

DualPeaks avatar Jul 19 '21 21:07 DualPeaks

@r-ndom-developer @Lazy-Developer-here @dionkas @jailsondamasceno - I have only reported the lack of link in the error message. You are not reporting the same as what I'm seeing and reported. If you have an additional issue you must provide:

  • query you're executing
  • index you made (screenshot)
  • error message

In my case, I was able to make an index & run my code. I am not blocked at all. Additionally this was for a class. My students were also able to make the index successfully (though many of them first made typos in the collection name, field names, or direction). In all cases we corrected the index and the code ran successfully.

Please share the details of your failing index

charles-allen avatar Jul 19 '21 22:07 charles-allen