question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

firebase deploy firebase:indexes fails when any index was already created

See original GitHub issue

[REQUIRED] Environment info

firebase-tools: 7.0.2

Platform: Ubuntu

[REQUIRED] Test case

v1: indexes.json

{
  "indexes": [
    {
      "collectionGroup": "authors",
      "queryScope": "COLLECTION",
      "fields": [
        {
          "fieldPath": "name",
          "order": "ASCENDING"
        },
        {
          "fieldPath": "born",
          "order": "ASCENDING"
        }
      ]
    }
  ]
}

v2: indexes.json: added new index

{
  "indexes": [
    {
      "collectionGroup": "authors",
      "queryScope": "COLLECTION",
      "fields": [
        {
          "fieldPath": "name",
          "order": "ASCENDING"
        },
        {
          "fieldPath": "born",
          "order": "ASCENDING"
        }
      ]
    },
    {
      "collectionGroup": "authors",
      "queryScope": "COLLECTION",
      "fields": [
        {
          "fieldPath": "name",
          "order": "ASCENDING"
        },
        {
          "fieldPath": "born",
          "order": "DESCENDING"
        }
      ]
    }
  ]
}

[REQUIRED] Steps to reproduce

  1. run firebase deploy --only firestore:indexes with first version of indexes.json
  2. update file with additional index and re-run

[REQUIRED] Expected behavior

Both commands are successful and target firestore database contains both indices

[REQUIRED] Actual behavior

First run succeeds, but latter fails with error: Error: HTTP Error: 409, index already exists. Only first index is present.

Workaround

  1. Delete all indexes before deploy
  2. Place in indexes.json only indexes not present in database.

It would seems this has been caused by: #1120

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lizbrownwoodcommented, Dec 1, 2020

Same problem. is there a fix for this?

1reaction
manwithsteelnervescommented, Nov 4, 2020

Even we see this error. I deleted the existing indexes but still its throwing the error saying “index already exists”. But the new indexes doesn’t have any duplicates (I delete the indexes before submitting the indexes if any).

It would be great if Firestore just ignores the duplicate index and proceed with the operation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manage indexes in Cloud Firestore - Firebase - Google
Create a missing index through an error message. Use the Firebase console. Remove indexes; Use the Firebase CLI; Index build time. Listing all...
Read more >
Error: path-to-file/firestore.indexes.json does not exist
Your firebase.json files has an instruction to deploy security rules and predefined indexes to Firestore here:
Read more >
Managing indexes | Firestore - Google Cloud
Create a missing index through an error message; Use the Google Cloud Platform Console ... but these links will always open in the...
Read more >
Indexes - Full-Stack Firebase
Indexes are required in Cloud Firestore whenever you want to use two where-clauses in a single query. ... This query would require indexes...
Read more >
Firebase deploy functions fails - Atlassian Community
rules already up to date, skipping upload... ✓ firestore: deployed indexes in firestore.indexes.json successfully ✓ functions: functions ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found