Skip to content

Incorrect firebase firestore:indexes output generated #7629

Description

@andreibarabas

[REQUIRED] Environment info

firebase-tools: 13.6.0

Platform: macOS

[REQUIRED] Test case

Given 2 composite indexes, created via the FAILED_PRECONDITION provided link

Screenshot 2024-09-07 at 06 33 54

[REQUIRED] Steps to reproduce

Run the firebase firestore:indexes CLI command to output the indexes. As you will see, the indexes are duplicated, because the __name__ is stripped off https://github.com/firebase/firebase-tools/blob/master/src/firestore/api.ts#L187

    {
      "collectionGroup": "random-collection",
      "queryScope": "COLLECTION_GROUP",
      "fields": [
        {
          "fieldPath": "a",
          "order": "ASCENDING"
        },
        {
          "fieldPath": "b",
          "order": "DESCENDING"
        }
      ]
    },
    {
      "collectionGroup": "random-collection",
      "queryScope": "COLLECTION_GROUP",
      "fields": [
        {
          "fieldPath": "a",
          "order": "ASCENDING"
        },
        {
          "fieldPath": "b",
          "order": "DESCENDING"
        }
      ]
    },

[REQUIRED] Expected behavior

The __name__ to also be included, as that is the difference between both

[REQUIRED] Actual behavior

The current duplication is a problem because when you take the index file from the sandbox env and deploy it to production, you think all the indexes are created, but in fact only one of the 2 is. And thus you reach a FAILED_PRECONDITION on production

While this example is exaggerated in the sense that probably you would not have 2 indexes like this, the bigger issue is if you have an index with a __name__ order that is not exactly as the default sort order, then it's not properly generated when moving from sandbox to production

Activity

  1. aalej commented on Sep 10, 2024

    @aalej
    Contributor

    Hey @andreibarabas, thanks for the detailed report and sharing your observations! I was able to reproduce the issue you mentioned. Sharing the mcve here. Let me raise this to our engineering team so they can take a look. I’ll also mark this issue as reproducible .

  2. andreibarabas commented on Sep 11, 2024

    @andreibarabas
    Author

    thanks @aalej . the mcve looks solid. thanks for adding the extra touch ;)

  3. tonyay163 commented on Feb 28, 2025

    @tonyay163

    @aalej, is this something that will be prioritized? Not being able to handle descending __name__ indexes means that this is not usable for me

  4. glumb commented on Jul 10, 2025

    @glumb
    Contributor

    @aalej its been a few weeks now. Is there anything missing to merge the PR?

  5. self-assigned this
    on Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions