firebase-tools-ui icon indicating copy to clipboard operation
firebase-tools-ui copied to clipboard

Cannot access secondary bucket using emulator

Open paymog opened this issue 3 years ago • 7 comments

[REQUIRED] Environment info

firebase-tools: 11.6.0

Platform: macOS

[REQUIRED] Test case

  1. Create a firebase project with storage initiated
  2. Create a second bucket for your project
  3. Create two targets for your project, one target which points at the default bucket and a second target which points at your second bucket
  4. Edit your firebase.json storage config to look like so that different rule files are used with different targets (and different buckets)
  "storage": [
    {
      "rules": "firebase-config/public-storage.rules",
      "target": "public",
      "bucket": "lookieloo-app-public"
    },
    {
      "rules": "firebase-config/private-storage.rules",
      "target": "default",
      "bucket": "lookieloo-app.appspot.com"
    }
  ],
  1. set both rule files to be broadly open
rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read;
      allow write;
    }
  }
}
  1. start your emulator
  2. go to the storage tab
  3. change to the secondary bucket
  4. notice the page doesn't load image
  5. Look at emulator logs and see the following: ⚠ Permission denied because no Storage ruleset is currently loaded, check your rules for syntax errors.

[REQUIRED] Steps to reproduce

See above

[REQUIRED] Expected behavior

I expect to be able to view my second bucket in the emulator

[REQUIRED] Actual behavior

I'm not allowed to view the second bucket (or interact with it through code). Here's the output of starting my emulator with debug logging:

 8:27PM /Users/paymahn/code/lookieloo paymahn/thumbnail ✖ ✱ ◼
 ❮❮❮ firebase emulators:start --debug
[2022-08-22T02:27:23.919Z] > 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-08-22T02:27:23.920Z] > authorizing via signed-in user ([email protected])
[2022-08-22T02:27:23.947Z] openjdk version "18.0.2" 2022-07-19
OpenJDK Runtime Environment Homebrew (build 18.0.2+0)
OpenJDK 64-Bit Server VM Homebrew (build 18.0.2+0, mixed mode, sharing)

[2022-08-22T02:27:23.950Z] Parsed Java major version: 18
i  emulators: Starting emulators: auth, functions, firestore, database, storage {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: auth, functions, firestore, database, storage"}}
[2022-08-22T02:27:23.955Z] [hub] writing locator at /var/folders/2b/1gkdb80j6pq4m61pm1nsdmhh0000gp/T/hub-lookieloo-app.json
⚠  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: hosting, pubsub, eventarc {"metadata":{"emulator":{"name":"functions"},"message":"The following emulators are not running, calls to these services from the Functions emulator will affect production: \u001b[1mhosting, pubsub, eventarc\u001b[22m"}}
⚠  Your requested "node" version "16" doesn't match your global version "17". Using node@17 from host. {"metadata":{"emulator":{"name":"functions"},"message":"Your requested \"node\" version \"16\" doesn't match your global version \"17\". Using node@17 from host."}}
[2022-08-22T02:27:23.963Z] defaultcredentials: writing to file /Users/paymahn/.config/firebase/paymahn1_gmail_com_application_default_credentials.json
[2022-08-22T02:27:23.964Z] Setting GAC to /Users/paymahn/.config/firebase/paymahn1_gmail_com_application_default_credentials.json {"metadata":{"emulator":{"name":"functions"},"message":"Setting GAC to /Users/paymahn/.config/firebase/paymahn1_gmail_com_application_default_credentials.json"}}
[2022-08-22T02:27:23.965Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/lookieloo-app/adminSdkConfig [none]
[2022-08-22T02:27:25.977Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/lookieloo-app/adminSdkConfig 200
[2022-08-22T02:27:25.979Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/lookieloo-app/adminSdkConfig {"projectId":"lookieloo-app","databaseURL":"https://lookieloo-app-default-rtdb.firebaseio.com","storageBucket":"lookieloo-app.appspot.com","locationId":"us-central"}
[2022-08-22T02:27:26.295Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: projectId"}}
[2022-08-22T02:27:26.296Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[2022-08-22T02:27:26.296Z] Starting Firestore Emulator with command {"binary":"java","args":["-Dgoogle.cloud_firestore.debug_log_level=FINE","-Duser.language=en","-jar","/Users/paymahn/.cache/firebase/emulators/cloud-firestore-emulator-v1.14.4.jar","--host","localhost","--port",8080,"--rules","/Users/paymahn/code/lookieloo/firebase-config/firestore.rules","--functions_emulator","localhost:5001"],"optionalArgs":["port","webchannel_port","host","rules","functions_emulator","seed_from_export"],"joinArgs":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {\"binary\":\"java\",\"args\":[\"-Dgoogle.cloud_firestore.debug_log_level=FINE\",\"-Duser.language=en\",\"-jar\",\"/Users/paymahn/.cache/firebase/emulators/cloud-firestore-emulator-v1.14.4.jar\",\"--host\",\"localhost\",\"--port\",8080,\"--rules\",\"/Users/paymahn/code/lookieloo/firebase-config/firestore.rules\",\"--functions_emulator\",\"localhost:5001\"],\"optionalArgs\":[\"port\",\"webchannel_port\",\"host\",\"rules\",\"functions_emulator\",\"seed_from_export\"],\"joinArgs\":false}"}}
i  firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
[2022-08-22T02:27:26.726Z] Aug 21, 2022 8:27:26 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start
INFO: Started WebSocket server on ws://localhost:62401
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:27:26 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start\nINFO: Started WebSocket server on ws://localhost:62401\n"}}
[2022-08-22T02:27:26.736Z] API endpoint: http://localhost:8080
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:
 {"metadata":{"emulator":{"name":"firestore"},"message":"API endpoint: http://localhost:8080\nIf you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:\n"}}
[2022-08-22T02:27:26.736Z]
   export FIRESTORE_EMULATOR_HOST=localhost:8080

Dev App Server is now running.

 {"metadata":{"emulator":{"name":"firestore"},"message":"\n   export FIRESTORE_EMULATOR_HOST=localhost:8080\n\nDev App Server is now running.\n\n"}}
[2022-08-22T02:27:26.820Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/lookieloo-app [none]
[2022-08-22T02:27:27.208Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/lookieloo-app 200
[2022-08-22T02:27:27.209Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/lookieloo-app {"projectId":"lookieloo-app","projectNumber":"221274282648","displayName":"Lookieloo","name":"projects/lookieloo-app","resources":{"hostingSite":"lookieloo-app","realtimeDatabaseInstance":"lookieloo-app-default-rtdb","storageBucket":"lookieloo-app.appspot.com","locationId":"us-central"},"state":"ACTIVE","etag":"1_4baaaa7a-b8ae-40c8-b797-7565dedd198c"}
[2022-08-22T02:27:27.211Z] database rules config:  [{"instance":"lookieloo-app-default-rtdb","rules":"/Users/paymahn/code/lookieloo/firebase-config/database.rules.json"}]
[2022-08-22T02:27:27.217Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: projectId"}}
[2022-08-22T02:27:27.218Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: auto_download"}}
[2022-08-22T02:27:27.218Z] Ignoring unsupported arg: rules {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: rules"}}
[2022-08-22T02:27:27.218Z] Starting Database Emulator with command {"binary":"java","args":["-Duser.language=en","-jar","/Users/paymahn/.cache/firebase/emulators/firebase-database-emulator-v4.8.0.jar","--host","localhost","--port",9000,"--functions_emulator_host","localhost","--functions_emulator_port",5001],"optionalArgs":["port","host","functions_emulator_port","functions_emulator_host"],"joinArgs":false} {"metadata":{"emulator":{"name":"database"},"message":"Starting Database Emulator with command {\"binary\":\"java\",\"args\":[\"-Duser.language=en\",\"-jar\",\"/Users/paymahn/.cache/firebase/emulators/firebase-database-emulator-v4.8.0.jar\",\"--host\",\"localhost\",\"--port\",9000,\"--functions_emulator_host\",\"localhost\",\"--functions_emulator_port\",5001],\"optionalArgs\":[\"port\",\"host\",\"functions_emulator_port\",\"functions_emulator_host\"],\"joinArgs\":false}"}}
i  database: Database Emulator logging to database-debug.log {"metadata":{"emulator":{"name":"database"},"message":"Database Emulator logging to \u001b[1mdatabase-debug.log\u001b[22m"}}
[2022-08-22T02:27:27.740Z] 20:27:27.739 [NamespaceSystem-akka.actor.default-dispatcher-4] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
 {"metadata":{"emulator":{"name":"database"},"message":"20:27:27.739 [NamespaceSystem-akka.actor.default-dispatcher-4] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started\n"}}
[2022-08-22T02:27:27.820Z] 20:27:27.820 [main] INFO com.firebase.server.forge.App$ - Listening at localhost:9000
 {"metadata":{"emulator":{"name":"database"},"message":"20:27:27.820 [main] INFO com.firebase.server.forge.App$ - Listening at localhost:9000\n"}}
[2022-08-22T02:27:30.700Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"storage"},"message":"Ignoring unsupported arg: port"}}
[2022-08-22T02:27:31.048Z] Temp file directory for storage emulator: /var/folders/2b/1gkdb80j6pq4m61pm1nsdmhh0000gp/T/firebase/storage/blobs {"metadata":{"emulator":{"name":"storage"},"message":"Temp file directory for storage emulator: /var/folders/2b/1gkdb80j6pq4m61pm1nsdmhh0000gp/T/firebase/storage/blobs"}}
[2022-08-22T02:27:31.320Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: auto_download"}}
[2022-08-22T02:27:31.320Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: port"}}
[2022-08-22T02:27:31.320Z] Starting Emulator UI with command {"binary":"node","args":["/Users/paymahn/.cache/firebase/emulators/ui-v1.9.0/server/server.js"],"optionalArgs":[],"joinArgs":false} {"metadata":{"emulator":{"name":"ui"},"message":"Starting Emulator UI with command {\"binary\":\"node\",\"args\":[\"/Users/paymahn/.cache/firebase/emulators/ui-v1.9.0/server/server.js\"],\"optionalArgs\":[],\"joinArgs\":false}"}}
i  ui: Emulator UI logging to ui-debug.log {"metadata":{"emulator":{"name":"ui"},"message":"Emulator UI logging to \u001b[1mui-debug.log\u001b[22m"}}
[2022-08-22T02:27:31.413Z] Web / API server started at localhost:4000
 {"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at localhost:4000\n"}}
i  functions: Watching "/Users/paymahn/code/lookieloo/functions" for Cloud Functions... {"metadata":{"emulator":{"name":"functions"},"message":"Watching \"/Users/paymahn/code/lookieloo/functions\" for Cloud Functions..."}}
[2022-08-22T02:27:31.605Z] Validating nodejs source
[2022-08-22T02:27:32.335Z] > [functions] package.json contents: {
  "name": "functions",
  "scripts": {
    "lint": "eslint .",
    "build": "tsc",
    "build:watch": "tsc --watch",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "16"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "^10.0.2",
    "firebase-functions": "^3.18.0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.12.0",
    "@typescript-eslint/parser": "^5.12.0",
    "eslint": "^8.9.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-import": "^2.25.4",
    "firebase-functions-test": "^0.2.0",
    "typescript": "^4.5.4"
  },
  "private": true
}
[2022-08-22T02:27:32.335Z] Building nodejs source
[2022-08-22T02:27:32.336Z] Analyzing nodejs backend spec
[2022-08-22T02:27:32.337Z] Could not find functions.yaml. Must use http discovery
[2022-08-22T02:27:32.396Z] Aug 21, 2022 8:27:32 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:27:32 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-08-22T02:27:32.413Z] Serving at port 9005

[2022-08-22T02:27:32.421Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/lookieloo-app/adminSdkConfig [none]
[2022-08-22T02:27:32.424Z] Aug 21, 2022 8:27:32 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketChannelHandler initChannel
INFO: Connected to new websocket client
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:27:32 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketChannelHandler initChannel\nINFO: Connected to new websocket client\n"}}
[2022-08-22T02:27:32.439Z] Got response from /__/functions.yaml {"endpoints":{"helloWorld2":{"platform":"gcfv1","labels":{},"callableTrigger":{},"entryPoint":"helloWorld2"}},"specVersion":"v1alpha1","requiredAPIs":[]}
[2022-08-22T02:27:32.443Z] shutdown requested via /__/quitquitquit

✔  functions: Loaded functions definitions from source: helloWorld2. {"metadata":{"emulator":{"name":"functions"},"message":"Loaded functions definitions from source: helloWorld2."}}
✔  functions[us-central1-helloWorld2]: http function initialized (http://localhost:5001/lookieloo-app/us-central1/helloWorld2). {"metadata":{"emulator":{"name":"functions"},"message":"\u001b[1mhttp\u001b[22m function initialized (http://localhost:5001/lookieloo-app/us-central1/helloWorld2)."}}
[2022-08-22T02:27:32.447Z] >>> [apiv2][query] PUT http://localhost:9000/.settings/rules.json ns=lookieloo-app-default-rtdb
[2022-08-22T02:27:32.447Z] >>> [apiv2][body] PUT http://localhost:9000/.settings/rules.json "{\n  /* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */\n  \"rules\": {\n    \".read\": false,\n    \".write\": false\n  }\n}\n"
[2022-08-22T02:27:32.571Z] 20:27:32.571 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO com.firebase.core.namespace.NamespaceActor - lookieloo-app-default-rtdb successfully activated FBKV (SurveyIdle(0)) wait: 54ms, init: 0ms
 {"metadata":{"emulator":{"name":"database"},"message":"20:27:32.571 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO com.firebase.core.namespace.NamespaceActor - lookieloo-app-default-rtdb successfully activated FBKV (SurveyIdle(0)) wait: 54ms, init: 0ms\n"}}
[2022-08-22T02:27:32.598Z] 20:27:32.598 [NamespaceSystem-blocking-namespace-operation-dispatcher-6:lookieloo-app-default-rtdb$1659282509:] INFO com.firebase.core.namespace.StateManager - Namespace lookieloo-app-default-rtdb status Active to Active
 {"metadata":{"emulator":{"name":"database"},"message":"20:27:32.598 [NamespaceSystem-blocking-namespace-operation-dispatcher-6:lookieloo-app-default-rtdb$1659282509:] INFO com.firebase.core.namespace.StateManager - Namespace lookieloo-app-default-rtdb status Active to Active\n"}}
[2022-08-22T02:27:32.610Z] <<< [apiv2][status] PUT http://localhost:9000/.settings/rules.json 200
[2022-08-22T02:27:32.611Z] <<< [apiv2][body] PUT http://localhost:9000/.settings/rules.json {"status":"ok"}

┌─────────────────────────────────────────────────────────────┐
│ ✔  All emulators ready! It is now safe to connect your app. │
│ i  View Emulator UI at http://localhost:4000                │
└─────────────────────────────────────────────────────────────┘

┌────────────────┬────────────────┬─────────────────────────────────┐
│ Emulator       │ Host:Port      │ View in Emulator UI             │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Authentication │ localhost:9099 │ http://localhost:4000/auth      │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Functions      │ localhost:5001 │ http://localhost:4000/functions │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Firestore      │ localhost:8080 │ http://localhost:4000/firestore │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Database       │ localhost:9000 │ http://localhost:4000/database  │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Storage        │ localhost:9199 │ http://localhost:4000/storage   │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Eventarc       │ localhost:9299 │ n/a                             │
└────────────────┴────────────────┴─────────────────────────────────┘
  Emulator Hub running at localhost:4400
  Other reserved ports: 4500

Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.

[2022-08-22T02:27:34.239Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/lookieloo-app/adminSdkConfig 200
[2022-08-22T02:27:34.240Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/lookieloo-app/adminSdkConfig {"projectId":"lookieloo-app","databaseURL":"https://lookieloo-app-default-rtdb.firebaseio.com","storageBucket":"lookieloo-app.appspot.com","locationId":"us-central"}
[2022-08-22T02:27:34.445Z] Aug 21, 2022 8:27:34 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketChannelHandler channelClosed
INFO: Websocket client disconnected
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:27:34 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketChannelHandler channelClosed\nINFO: Websocket client disconnected\n"}}
[2022-08-22T02:27:34.764Z] Aug 21, 2022 8:27:34 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:27:34 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-08-22T02:27:34.773Z] Aug 21, 2022 8:27:34 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:27:34 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-08-22T02:27:34.803Z] Aug 21, 2022 8:27:34 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketChannelHandler initChannel
INFO: Connected to new websocket client
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:27:34 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketChannelHandler initChannel\nINFO: Connected to new websocket client\n"}}
[2022-08-22T02:27:38.802Z] Aug 21, 2022 8:27:38 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:27:38 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-08-22T02:27:40.847Z] Aug 21, 2022 8:27:40 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:27:40 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-08-22T02:27:42.888Z] Aug 21, 2022 8:27:42 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:27:42 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-08-22T02:27:44.935Z] Aug 21, 2022 8:27:44 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:27:44 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-08-22T02:27:46.970Z] Aug 21, 2022 8:27:46 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:27:46 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
⚠  Permission denied because no Storage ruleset is currently loaded, check your rules for syntax errors. {"metadata":{"emulator":{"name":"storage"},"message":"Permission denied because no Storage ruleset is currently loaded, check your rules for syntax errors."}}
[2022-08-22T02:28:10.051Z] Aug 21, 2022 8:28:10 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:28:10 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-08-22T02:28:12.264Z] Aug 21, 2022 8:28:12 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:28:12 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
⚠  Permission denied because no Storage ruleset is currently loaded, check your rules for syntax errors. {"metadata":{"emulator":{"name":"storage"},"message":"Permission denied because no Storage ruleset is currently loaded, check your rules for syntax errors."}}
[2022-08-22T02:28:12.529Z] Aug 21, 2022 8:28:12 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketChannelHandler channelClosed
INFO: Websocket client disconnected
 {"metadata":{"emulator":{"name":"firestore"},"message":"Aug 21, 2022 8:28:12 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketChannelHandler channelClosed\nINFO: Websocket client disconnected\n"}}

paymog avatar Aug 22 '22 02:08 paymog

+1 I am in the same exact situation. Did you find a solution ?

sk8killer avatar Dec 09 '22 15:12 sk8killer

@sk8killer I didn't find a solution and ended up migrating away from firebase.

paymog avatar Dec 09 '22 17:12 paymog

Whats in your .firebase rc file for this project?

If I use a bucket that matches the storage target that's required for multi-storage config it seems to work.

firebase target:apply storage public asdf firebase target:apply storage public fdsa

.firebaserc:

...

    "storage": [
    {
    "rules": "storage.rules",
       "target": "public",
      "bucket": "fdsa"
    },
    {
    "rules": "storage.rules",
      "target": "default",
      "bucket": "asdf"
    }
  ],
...

firebase.json

 "storage": [
    {
    "rules": "storage.rules",
       "target": "public",
      "bucket": "asdf"
    },
    {
    "rules": "storage.rules",
      "target": "default",
      "bucket": "fdsa"
    }
  ],

So I think the workaround/intention here is to have the bucket match the declared one in .firebaserc (and the project in the firebase console).

Looking at the code, this lookup based on bucketId may need to be based on the target instead: https://cs.opensource.google/firebase-sdk/firebase-tools/+/master:src/emulator/storage/apis/firebase.ts;drc=95799e1db587371ba800b2578d51358c1657e898;l=77

I'll discuss with the team next week

christhompsongoogle avatar Jan 14 '23 01:01 christhompsongoogle

I'm bumping into the same problem. The mentioned workaround doesn't seem to work for me because I believe the syntax for .firebaserc is invalid. When I use the format as mentioned in the workaround, I get the error message that the deploy target hasn't been configured. Executing firebase target:apply storage <targetname> … results in unexpected errors because according to the logs it expects an array but gets an object and thus cannot use the include method of arrays. Removing the "storage" part in .firebaserc and then retrying the target:apply command populated the "storage" part successfully but with a completely different syntax. Thus I believe the following syntax is wrong for .firebaserc:

...
  "storage": [
    {
      "rules": "some.rules",
      "target": "sometarget",
      "bucket": "somebucket"
    },
    ...
  ],
...

and should instead be something like what gets added when using the target:apply command:

...
  "storage": {
    "sometarget": [
      "somebucket"
    ],
    ...
  },
...

But then it isn't clear to me how I would reference the rules in .firebaserc (and if that is needed).

~Also, even though the emulators say "Permission denied because no Storage ruleset is currently loaded, check your rules for syntax errors.", when I retrieve the rules with the AdminSDK (await getSecurityRules(getApp("someapp")).getStorageRuleset("somebucket")).source[0].content I get the deployed rules instead of any emulated ones.~

KantiKuijk avatar May 22 '23 10:05 KantiKuijk

Well, embarrassingly enough, my problem had nothing to do with this issue, just sheer stupidity on my part. I'm leaving my previous post because the issue regarding syntax of .firebaserc is still the case.

Maybe it could be useful though to alter the error message Permission denied because no Storage ruleset is currently loaded, check your rules for syntax errors. to include some reference to the bucket/target that was being accessed. It could help debugging.

KantiKuijk avatar May 26 '23 20:05 KantiKuijk

For me, what happened here was that I was only creating targets and rules for new buckets, but when you visit http://127.0.0.1:4000/storage it defaults to redirect you to your apps default bucket. Because I didn't set up rules for that, I got the error Permission denied because no Storage ruleset is currently loaded.

When I manually appended the bucket name to the URL (http://127.0.0.1:4000/storage/testbucket) it works. So the solution is simply to ensure you always have a ruleset for your default bucket.

Adding the offending bucket name to the debug output would be helpful in debugging issues like this.

Also, as noted above the syntax in some answers is wrong. This worked for me:

.firebaserc

  "targets": {
    "my-project": {
      "storage": {
        "default": [
          "my-app-dev.appspot.com"
        ],
        "secondTarget": [
          "my-app-dev-secondBucket"
        ]
      }
    }
  },

firebase.json

  "storage": [
    {
      "target": "default",
      "rules": "path/to/storage.rules"
    },
    {
      "target": "secondTarget",
      "rules": "path/to/secondBucket.rules"
    }
  ]

OskarGroth avatar Oct 12 '23 14:10 OskarGroth

I am getting this error too... for my default bucket it is using the emulator location, but for my second bucket it is always hitting https://firebasestorage.googleapis.com/v0/b/

I have tried following the instructions given in
https://stackoverflow.com/questions/68340724/how-do-i-create-additional-buckets-in-firebase-cloud-storage-emulator https://firebase.google.com/docs/cli/targets#set-up-deploy-target-storage-database multiple times, but nothing works...

akashdeep-sarin avatar Nov 19 '23 13:11 akashdeep-sarin