Skip to content

Cannot deploy indexes in a project with multiple firestore dbs: TypeError: Cannot read properties of undefined (reading 'map') #8114

Closed

Description

@jmysliv

[REQUIRED] Environment info

firebase-tools: 13.29.1

Platform: macOS

[REQUIRED] Test case

A firebase project with one default firestore database and one named firestore database.

[REQUIRED] Steps to reproduce

  1. Create firebase project with firebase init
  2. Create two firestore databases (one default and one named)
  3. Edit firebase.json as described here: https://firebase.google.com/docs/cli#firestore-multiple-dbs
  4. Edit firestore.indexes.json: add some indexes, i.ex.
{
  "indexes": [
    {
      "collectionGroup": "users",
      "queryScope": "COLLECTION",
      "fields": [
        {
          "fieldPath": "language",
          "order": "ASCENDING"
        },
        {
          "fieldPath": "age",
          "order": "ASCENDING"
        }
      ]
    }
  ]
}
  1. Try to deploy those indexes:
firebase deploy --only firestore:indexes

[REQUIRED] Expected behavior

Indexes should be deployed for both databases.

[REQUIRED] Actual behavior

You will see the following logs:

[info] 
[info] === Deploying to 'project_id'...
[info] 
[info] i  deploying firestore 
[info] i  firestore: deploying indexes... 
[debug] [2025-01-13T14:58:39.744Z] TypeError: Cannot read properties of undefined (reading 'map')
    at deployIndexes (<path_to_node_modules>/firebase-tools/lib/deploy/firestore/deploy.js:24:38)
    at default_1 (<path_to_node_modules>/firebase-tools/lib/deploy/firestore/deploy.js:42:46)
    at chain (<path_to_node_modules>/firebase-tools/lib/deploy/index.js:40:15)
    at deploy (<path_to_node_modules>/firebase-tools/lib/deploy/index.js:101:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[error] 
[error] Error: An unexpected error has occurred.

Activity

  1. aalej commented on Jan 13, 2025

    @aalej
    Contributor

    Thanks for providing detailed steps to reproduce the issue as well as the error raised, @jmysliv! I'm able to replicate the error you encountered. Let me raise this to our engineering team.

    Internal tracking bug: b/389699819

  2. UmarFarooq-Ch commented on Feb 17, 2025

    @UmarFarooq-Ch

    any update on this bug?

  3. jaceknijaki commented on Feb 20, 2025

    @jaceknijaki

    Similar problem occurs when trying to run firebase deploy --only firestore:rules when having multiple databases. In such scenario there is no error, but also nothing happens:

    % firebase deploy --only firestore:rules  
    
    === Deploying to '***'...
    
    i  deploying firestore
    
    ✔  Deploy complete!
    
    
  4. kervyntan commented on Apr 9, 2025

    @kervyntan

    Hi, has anyone managed to fix this? Currently struggling with this

  5. itsikbelson-spotlight commented on Apr 25, 2025

    @itsikbelson-spotlight

    Hi, has anyone managed to fix this? Currently struggling with this

    I managed to workaround it when deploying indexes for one firestore database by using an object instead of an array in the firestore definition in firebase.json:

      "firestore": {
        "database": "<MY_DATABASE>",
        "rules": "firestore.rules",
        "indexes": "firestore.indexes.json"
      }
    
  6. duncannz commented on May 2, 2025

    @duncannz

    The workaround provided by @itsikbelson-spotlight also worked for me!

  7. jakenotjay commented on Oct 10, 2025

    @jakenotjay

    Still occurs for me, when using the documented format:

      "firestore": [
        {
          "database": "(default)",
          "rules": "firestore.default.rules",
          "indexes": "firestore.default.indexes.json"
        },
        {
          "database": "ecommerce",
          "rules": "firestore.ecommerce.rules",
          "indexes": "firestore.ecommerce.indexes.json"
        }
      ],
    

    Indexes result in an error, and rules deploy simply do nothing...

  8. naveenaviato commented on Oct 13, 2025

    @naveenaviato

    Any update on this?

  9. ayanko commented on Dec 27, 2025

    @ayanko

    I guess it's time to fix this ugly issue...

  10. added a commit that references this issue on Dec 30, 2025
    95b976b
  11. Digital-Coder commented on Mar 4, 2026

    @Digital-Coder

    Are there any blockers? It's been over a year now. Deploying indexes and rules to multiple databases in the same project is buggy.

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