Skip to content

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

Closed
@m6keller

Description

[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 ([email protected])
[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":"[email protected]","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

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions