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

CLI does not support deploying storage rules to multiple buckets #4752

Closed
m6keller opened this issue Jul 18, 2022 · 2 comments · Fixed by #4782
Closed

CLI does not support deploying storage rules to multiple buckets #4752

m6keller opened this issue Jul 18, 2022 · 2 comments · Fixed by #4782
Assignees

Comments

@m6keller
Copy link

m6keller commented Jul 18, 2022

[REQUIRED] Environment info

firebase-tools: 11.3.0

Platform: macOS

[REQUIRED] Test case

Deploy storage rules with firebase deploy --only storage with "firebase.json" containing the following:

"storage": [
		{
			"target": "main",
			"rules": "rules/storage.rules"
		}
	],

[REQUIRED] Steps to reproduce

Use the following directory structure:

- rules 
  - storage.rules 
- firebase.json
- .firebaserc

Run following with Firebase CLI to set target:

firebase target:apply storage main my-bucket.appspot.com

This adds the following to the ".firebaserc" file:

"storage": {
        "main": [
          "my-bucket.appspot.com"
        ]
      }

In firebase.json, include:

"storage": [
		{
			"target": "main",
			"rules": "rules/storage.rules"
		}
	],

Then, run firebase deploy --only storage

[REQUIRED] Expected behavior

After running firebase deploy --only storage, storage rules should deploy to Firebase console with following message:

✔  storage: released rules rules/storage.rules to firebase.storage 

✔  Deploy complete! 

[REQUIRED] Actual behavior

firebase deploy --only storage --debug
Terminal output:

[2022-07-18T22:52:22.638Z] Object ".emulators.storage" in "firebase.json" has unknown property: {"additionalProperty":"rules"}
[2022-07-18T22:52:22.645Z] > 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"]
[2022-07-18T22:52:22.646Z] > authorizing via signed-in user (matthew@gmail.com)
[2022-07-18T22:52:22.646Z] [iam] checking project project-name for permissions ["firebase.projects.get","firebaserules.releases.create","firebaserules.releases.update","firebaserules.rulesets.create"]
[2022-07-18T22:52:22.649Z] >>> [apiv2][query] POST https://cloudresourcemanager.googleapis.com/v1/projects/project-name:testIamPermissions [none]
[2022-07-18T22:52:22.649Z] >>> [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/project-name:testIamPermissions {"permissions":["firebase.projects.get","firebaserules.releases.create","firebaserules.releases.update","firebaserules.rulesets.create"]}
[2022-07-18T22:52:22.858Z] <<< [apiv2][status] POST https://cloudresourcemanager.googleapis.com/v1/projects/project-name:testIamPermissions 200
[2022-07-18T22:52:22.859Z] <<< [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/project-name:testIamPermissions {"permissions":["firebase.projects.get","firebaserules.releases.create","firebaserules.releases.update","firebaserules.rulesets.create"]}

=== Deploying to 'project-name'...
i  deploying storage 
[2022-07-18T22:52:22.862Z] >>> [apiv2][query] GET https://appengine.googleapis.com/v1/apps/project-name [none]
[2022-07-18T22:52:23.363Z] <<< [apiv2][status] GET https://appengine.googleapis.com/v1/apps/project-name 200
[2022-07-18T22:52:23.363Z] <<< [apiv2][body] GET https://appengine.googleapis.com/v1/apps/project-name {"name":"apps/app-name","id":"project-name","authDomain":"gmail.com","locationId":"northamerica-northeast1","codeBucket":"staging.my-bucket.appspot.com","servingStatus":"SERVING","defaultHostname":"project-name.nn.r.appspot.com","defaultBucket":"my-bucket.appspot.com","serviceAccount":"my-account@appspot.gserviceaccount.com","gcrDomain":"us.gcr.io","databaseType":"CLOUD_FIRESTORE","featureSettings":{"splitHealthChecks":true,"useContainerOptimizedOs":true}}
[2022-07-18T22:52:23.491Z] TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:120:11)
    at Object.join (node:path:1172:7)
    at Config.path (/usr/local/lib/node_modules/firebase-tools/lib/config.js:123:45)
    at RulesDeploy.addFile (/usr/local/lib/node_modules/firebase-tools/lib/rulesDeploy.js:33:46)
    at /usr/local/lib/node_modules/firebase-tools/lib/deploy/storage/prepare.js:23:21
    at Array.forEach (<anonymous>)
    at default_1 (/usr/local/lib/node_modules/firebase-tools/lib/deploy/storage/prepare.js:19:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async chain (/usr/local/lib/node_modules/firebase-tools/lib/deploy/index.js:33:9)
    at async deploy (/usr/local/lib/node_modules/firebase-tools/lib/deploy/index.js:68:5)

Error: An unexpected error has occurred.

Other notes:
Running firebase deploy --only storage with firebase.json including the following works as expected:

"storage": {
		"rules": "rules/storage.rules"
	}

Also:
Running firebase deploy --only storage:main gives the following error in the terminal:
Filters specified with colons (e.g. --only functions:func1,functions:func2) are only supported for functions, hosting, and firestore

This is said to be a valid command (where main is the name of a storage target) in the Firebase CLI Docs

@m6keller m6keller added the bug label Jul 18, 2022
@egorkel-altexsoft
Copy link

Also can't use anymore in v11.3.0
firebase deploy --only storage:STORAGE_TARGET

Error is
Error: Filters specified with colons (e.g. --only functions:func1,functions:func2) are only supported for functions, hosting, and firestore

It is regression. And I think it's related to #4698

@egorkel-altexsoft
Copy link

Had to downgrade to v11.1.0

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

Successfully merging a pull request may close this issue.

4 participants