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

[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

About this issue

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

Most upvoted comments

Wait for some time and try re-deploying!

Faced the same error on 9.1.0, but tried again after waiting ~30 seconds and was successful.

I ran firebase deploy --only firestore:indexes

Same problem. is there a fix for this?

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.

I’m running into the same error. Is there debug info I can provide that is useful?