firebase / firebase-tools

The Firebase Command Line Tools
MIT License
3.97k stars 917 forks source link

Can no longer run emulators with --project=dummy #5170

Open athoma13 opened 1 year ago

athoma13 commented 1 year ago

In Version 11.13.0 of firebase-tools (and previous versions), I was able to launch the emulator with firebase emulators:start --import my-backup --inspect-functions --project=dummy

Since upgrading to 11.15.0, I get Error: Deploy target xxx not configured for project dummy. Configure with... (where xxx is a real deployment target).

I don't want the emulators to start with the same project name as a 'real' project (as I was doing previously)...

akauppi commented 1 year ago

Have you tried demo-dummy?

Somewhere in the documentation, Firebase mentions that any locally used projects should be named demo-{something}. This ensures they are not intertwined with the actual Firebase projects online.

athoma13 commented 1 year ago

Hi Asko,

Thank you for the suggestion. I tried with 'demo-'. Unfortunately I get the same error message. I have deployment targets for hosting in my .firebaserc file maybe I should add 'demo-' there (as the error message suggests), but that feels wrong...

On Tue, Oct 25, 2022 at 7:02 PM Asko Kauppi @.***> wrote:

Have you tried demo-dummy?

Somewhere in the documentation, Firebase mentions that any locally used projects should be named demo-{something}. This ensures they are not intertwined with the actual Firebase projects online.

— Reply to this email directly, view it on GitHub https://github.com/firebase/firebase-tools/issues/5170#issuecomment-1290224321, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMVSZAOVIOWBHRS4C2W2ATWE6O2ZANCNFSM6AAAAAARNTFHLY . You are receiving this because you authored the thread.Message ID: @.***>

ludwig432 commented 1 year ago

Yes I experience the same. Although I've used a dummy project name that was not corresponding to a real Firebase project. So that without the demo- prefix (as I've had it previously) I now get Error: Failed to get Firebase project dummy.

With the demo- prefix same as @athoma13.

ruben-sch commented 1 year ago

I have the same issue. Is there an update on this? @athoma13 @ludwig432 did you find any workaround?

christhompsongoogle commented 1 year ago

Please include a full set of repro instructions so we can track this down:

firebase.json Which projects are initialized Full output with --debug flag emabled

Thank you

norkje commented 1 year ago

I have created a simple sample project that showcases the issue between two versions of firebase-tools.

https://github.com/norkje/firebase-tools-5170

christhompsongoogle commented 1 year ago

Thank you norkje that's helpful. I narrowed down the issue to this line in the hosting config: "target": "public"

The actual error is being thrown inside of rc.ts

athoma13 commented 1 year ago

Sorry been away... I can confirm that @norkje repo accurately depicts my issue too. Thank you so much for posting! additional: Still happening in version 11.23.1

gugahoi commented 1 year ago

This is a pretty annoying problem. I've found out this was introduced on v11.14.2 so rolling back to v11.14.1 makes the emulators work again.

npm i -g firebase-tools@11.14.1
gugahoi commented 1 year ago

To further help in finding the fix, the debug logs when running the emulator fail after a call to firebase gets a 403. This is the relevant info I guess:

[2023-02-20T23:54:12.138Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/demo-flux [none]
[2023-02-20T23:54:13.132Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/demo-flux 403
[2023-02-20T23:54:13.132Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/demo-flux {"error":{"code":403,"message":"The caller does not have permission","status":"PERMISSION_DENIED"}}
[2023-02-20T23:54:13.133Z] HTTP Error: 403, The caller does not have permission

I have no idea why this call would be attempted as the logs correctly identify that this is a demo project

i  emulators: Detected demo project ID "demo-flux", emulated services will use a demo configuration and attempts to access non-emulated services for this project will fail. {"metadata":{"emulator":{"name":"hub"}
,"message":"Detected demo project ID \"demo-flux\", emulated services will use a demo configuration and attempts to access non-emulated services for this project will fail."}}
gugahoi commented 1 year ago

This is completely blocking me from updating to newer versions of the Firebase CLI. Given this seems to be a regression and there are 0 instructions on what the correct process is to rectify this problem, it's quite disappointing that it's not been given any attention in quite some time. Is there anything that can be done regarding this? What are the instructions for using local only projects (demo-...) with the emulators?

gugahoi commented 1 year ago

@joehan thanks for submitting a fix, I've tried the latest version and I am still having problems. It is still failing on the same request as above:

[2023-05-04T00:58:26.669Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/demo-flux [none]
[2023-05-04T00:58:27.232Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/demo-flux 403
[2023-05-04T00:58:27.233Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/demo-flux {"error":{"code":403,"message":"The caller does not have permission","status":"PERMISSION_DENIED"}}
[2023-05-04T00:58:27.235Z] HTTP Error: 403, The caller does not have permission

And to make sure it is using the correct version, I created an npm task to print the output of firebase --version:

❯ npm run version

> version
> firebase --version

11.30.0
joehan commented 1 year ago

Looks like I missed somewhere we're making a prod call - reopening this.

gugahoi commented 1 year ago

Soo sorry to do this again but the problem still stands. Am I doing something wrong?

❯ npm run version

> version
> firebase --version

12.0.0
[2023-05-09T23:32:14.720Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"storage"},"message":"Ignoring unsupported arg: port"}}
[2023-05-09T23:32:15.125Z] Temp file directory for storage emulator: /var/folders/nm/9bwr1b6554z0gw080h83_2g00000gn/T/firebase/storage/blobs {"metadata":{"emulator":{"name":"storage"},"message":"Temp file directory for storage emulator: /var/folders/nm/9bwr1b6554z0gw080h83_2g00000gn/T/firebase/storage/blobs"}}
[2023-05-09T23:32:15.129Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/demo-flux [none]
[2023-05-09T23:32:15.948Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/demo-flux 403
[2023-05-09T23:32:15.948Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/demo-flux {"error":{"code":403,"message":"The caller does not have permission","status":"PERMISSION_DENIED"}}
[2023-05-09T23:32:15.949Z] HTTP Error: 403, The caller does not have permission

If you can point me in the right direction I'd be more than happy to try to fix it but I have no knowledge of the codebase so it's an uphill battle for me.

ludwig432 commented 1 year ago

Ran back into this issue as I had to update the Firebase CLI to be able to use Python Cloud Functions...

No idea what exactly I'm doing here but it was a workaround to add the demo-myapp-development project to .firebaserc and just list all hosting targets from firebase.json in there (which in fact doesn't make much sense I feel).

But it resulted in the emulator being happy as it could now serve the hosting files for those targets:

i  hosting[app-staging]: Serving hosting files from: webapp-vue/dist/
✔  hosting[app-staging]: Local server: http://127.0.0.1:5000
i  hosting[app-production]: Serving hosting files from: webapp-vue/dist/
✔  hosting[app-production]: Local server: http://127.0.0.1:5006

So for example:

// firebase.json

{
//...
"hosting": [
    {
      "target": "app-staging",
      "public": "webapp-vue/dist/",
     //...
    },
    {
      "target": "app-production",
      "public": "webapp-vue/dist/",
      //...
    },
  ],
//...
}
// .firebaserc

{
  "projects": {
    "development": "demo-myapp-development",
    "staging": "myapp-staging",
    "production": "myapp-production",
  },
  "targets": {
    "demo-myapp-development": { // This entry is what I needed to add
      "hosting": {
        "app-staging": [
          "app-myapp-staging"
        ],
        "app-production": [
          "app-myapp-production"
        ]
      }
    },
    "myapp-staging": {
      "hosting": {
        "app-staging": [
          "app-myapp-staging"
        ]
      }
    },
    "myapp-production": {
      "hosting": {
        "app-production": [
          "app-myapp-production"
        ]
      }
    }
  }
}
gugahoi commented 6 months ago

It's 2024 and this is still a problem, I can't believe this regression has been ignored for this long! Running the latest version of the emulators still yields issues:

[2024-01-02T02:04:47.248Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/demo-flux [none]
[2024-01-02T02:04:47.807Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/demo-flux 403
[2024-01-02T02:04:47.807Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/demo-flux {"error":{"code":403,"message":"The caller does not have permission","status":"PERMISSION_DENIED"}}
[2024-01-02T02:04:47.808Z] HTTP Error: 403, The caller does not have permission

Please, can you document the correct way to use "demo" projects? You seem to recommend the usage of "demo" projects but have ignored this for over a year and still have not found a way to move forward. How disappointing.

image

joehan commented 6 months ago

Hey @gugahoi - apologies for the slow response here, looks like I missed your last response. It looks like there must be another leaky call from the emulators. Could you provide a full debug log for the failed run so that I can see where in the code this failed call is coming from?