Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error deploying Firestore rules when indexes not present #493

Closed
mbleigh opened this issue Oct 5, 2017 · 8 comments
Closed

Error deploying Firestore rules when indexes not present #493

mbleigh opened this issue Oct 5, 2017 · 8 comments
Assignees

Comments

@mbleigh
Copy link
Contributor

mbleigh commented Oct 5, 2017

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.
@cliveb
Copy link

cliveb commented Dec 14, 2017

@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

@samtstern
Copy link
Contributor

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

@cliveb
Copy link

cliveb commented Dec 14, 2017

@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"
  }
}

@samtstern
Copy link
Contributor

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

The latest is 3.16.0

@cliveb
Copy link

cliveb commented Dec 14, 2017

@samtstern oops my bad. CLI is firebase-tools@3.16.0 (v5.6.0 is my NPM)

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

@samtstern
Copy link
Contributor

samtstern commented Dec 14, 2017

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).

@cliveb
Copy link

cliveb commented Dec 14, 2017

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

joehan added a commit that referenced this issue Nov 13, 2019
Ignores node_modules when uploading local sources
@JoseAlz
Copy link

JoseAlz commented Aug 15, 2022


"firestore": {
    "firestore.rules": "firestore.rules"
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants