Firebase-tools: Error deploying Firestore rules when indexes not present

Created on 5 Oct 2017  Â·  7Comments  Â·  Source: firebase/firebase-tools

We need to make sure if rules but not indexes are not defined, deploys still work properly.

[debug] [2017-10-05T19:30:57.378Z] ----------------------------------------------------------------------
[debug] [2017-10-05T19:30:57.381Z] Command:       /usr/bin/node /home/myhome/.npm-global/bin/firebase deploy
[debug] [2017-10-05T19:30:57.381Z] CLI Version:   3.13.1
[debug] [2017-10-05T19:30:57.381Z] Platform:      linux
[debug] [2017-10-05T19:30:57.381Z] Node Version:  v6.11.3
[debug] [2017-10-05T19:30:57.381Z] Time:          Thu Oct 05 2017 13:30:57 GMT-0600 (MDT)
[debug] [2017-10-05T19:30:57.381Z] ----------------------------------------------------------------------
[debug] 
[debug] [2017-10-05T19:30:57.391Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2017-10-05T19:30:57.392Z] > authorizing via signed-in user
[debug] [2017-10-05T19:30:57.393Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/#project-name#  
 Thu Oct 05 2017 13:30:57 GMT-0600 (MDT)
[debug] [2017-10-05T19:30:57.804Z] <<< HTTP RESPONSE 200
[debug] [2017-10-05T19:30:57.805Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/#project-name#/tokens  
 Thu Oct 05 2017 13:30:57 GMT-0600 (MDT)
[debug] [2017-10-05T19:30:58.246Z] <<< HTTP RESPONSE 200
[info] 4
[info] 
[info] === Deploying to '#project-name#'...
[info] 
[info] i  deploying database, firestore, functions, hosting
[info] i  database: checking rules syntax...
[debug] [2017-10-05T19:30:58.971Z] >>> HTTP REQUEST PUT https://#project-name#.firebaseio.com/.settings/rules.json?dryRun=true {
  "rules": {
    ".read": "auth != null",
    ".write": "auth != null"
  }
}

 Thu Oct 05 2017 13:30:58 GMT-0600 (MDT)
[debug] [2017-10-05T19:30:59.371Z] <<< HTTP RESPONSE 200
[info] ✔  database: rules syntax is valid
[info] i  firestore: checking firestore.rules for compilation errors...
[debug] [2017-10-05T19:30:59.375Z] >>> HTTP REQUEST POST https://firebaserules.googleapis.com/v1/projects/#project-name#:test { source: { files: [ [Object] ] } } 
 Thu Oct 05 2017 13:30:59 GMT-0600 (MDT)
[debug] [2017-10-05T19:30:59.477Z] TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.join (path.js:1218:7)
    at Config.path (/home/myhome/.npm-global/lib/node_modules/firebase-tools/lib/config.js:149:37)
    at Object.prepare (/home/myhome/.npm-global/lib/node_modules/firebase-tools/lib/firestore/indexes.js:182:36)
    at _prepareIndexes (/home/myhome/.npm-global/lib/node_modules/firebase-tools/lib/deploy/firestore/prepare.js:24:54)
    at module.exports (/home/myhome/.npm-global/lib/node_modules/firebase-tools/lib/deploy/firestore/prepare.js:43:5)
    at _chain (/home/myhome/.npm-global/lib/node_modules/firebase-tools/lib/deploy/index.js:22:45)
    at /home/myhome/.npm-global/lib/node_modules/firebase-tools/lib/deploy/index.js:25:14
    at tryCatch (/home/myhome/.npm-global/lib/node_modules/firebase-tools/node_modules/rsvp/dist/rsvp.js:525:12)
    at invokeCallback (/home/myhome/.npm-global/lib/node_modules/firebase-tools/node_modules/rsvp/dist/rsvp.js:538:13)
[error] 
[error] Error: An unexpected error has occurred.

Most helpful comment

you could try running firebase init firestore to regenerate those files. Or you could also try dropping the firestore block from the JSON file (if you're not using firestore).

All 7 comments

@mbleigh I've encountered this issue trying to deploy a single page index.html on firebase for a simple startup company homepage. New project with latest FB NPM tools. Any ideas, I am going around in circles?

=== Hosting Setup

Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.

? What do you want to use as your public directory? public
? Configure as a single-page app (rewrite all urls to /index.html)? No
? File public/404.html already exists. Overwrite? No
i  Skipping write of public/404.html
? File public/index.html already exists. Overwrite? No
i  Skipping write of public/index.html

i  Writing configuration info to firebase.json...
i  Writing project information to .firebaserc...

✔  Firebase initialization complete!
clivebs-bigMac:website seebe$ firebase deploy

=== Deploying to 'paymanteau-00000001'...

i  deploying database, storage, firestore, hosting
i  database: checking rules syntax...
✔  database: rules syntax for database paymanteau-00000001 is valid
i  storage: checking storage.rules for compilation errors...
✔  storage: rules file storage.rules compiled successfully

Error: Error reading rules file firestore.rules
clivebs-bigMac:website seebe$ 

clivebs-bigMac:website seebe$ ls
database.rules.json index.html      public
firebase.json       package.json        storage.rules

@cliveb what version of the CLI are you running (firebase --version)? Also can you show your firebase.json file?

@samtstern

CLI -v
5.6.0

firebase.json

{
  "database": {
    "rules": "database.rules.json"
  },
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  },
  "storage": {
    "rules": "storage.rules"
  },
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  }
}

@cliveb that can't be the right version:
https://github.com/firebase/firebase-tools/releases

The latest is 3.16.0

@samtstern oops my bad. CLI is [email protected] (v5.6.0 is my NPM)

Do I need to regenerate or edit out reference to firestore rules in firebase.json?

you could try running firebase init firestore to regenerate those files. Or you could also try dropping the firestore block from the JSON file (if you're not using firestore).

I removed the firestore block and successfully deployed to Firebase. Thanks for your help here.

Was this page helpful?
0 / 5 - 0 ratings