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

default project does not act as the default with aliases added #4593

Open
dereekb opened this issue May 27, 2022 · 1 comment
Open

default project does not act as the default with aliases added #4593

dereekb opened this issue May 27, 2022 · 1 comment

Comments

@dereekb
Copy link

dereekb commented May 27, 2022

I recently added an alias so that I could pass a second .env variable when deploying my Cloud Functions, but I started getting the following error in my CI:

https://app.circleci.com/pipelines/github/dereekb/dbx-components/607/workflows/8b52bf87-f0c2-4f24-964a-bf9094d1d558/jobs/1359/parallel-runs/0/steps/0-105

As workaround, I now have to now specify --project=default. The work around seems fairly anti-pattern since I have to add --project=default to every firebase call that CI uses now.

dereekb/dbx-components@9b7fd20

Is default not really actually a default?

My updated .firebaserc that causes this issue for reference:

{
  "projects": {
    "default": "dereekb-components",
    "prod": "dereekb-components"
  }
}

[REQUIRED] Environment info

firebase-tools: 10.9.2

**Platform: macOS, Ubuntu (Docker node:16.14-bullseye) **

[REQUIRED] Test case

Open a project with both a default and an alias. Try running a functions that targets a project:

npx firebase hosting:channel:deploy test

[REQUIRED] Steps to reproduce

Add an alias to .firebaserc on a project that did not have one before that has CI or use Docker and does not use the --project parameters.

Outside of a Docker instance, you can do the above but clear with firebase use --clear.

npx firebase hosting:channel:deploy test --debug

Error: Failed to get Firebase project undefined. Please make sure the project exists and your account has permission to access it.
dereekb@dbMBP firebase-tools-default-issue % npx firebase hosting:channel:deploy test --debug
[2022-05-27T18:53:03.812Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/undefined [none]
[2022-05-27T18:53:04.116Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/undefined 403
[2022-05-27T18:53:04.117Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/undefined {"error":{"code":403,"message":"The caller does not have permission","status":"PERMISSION_DENIED"}}
[2022-05-27T18:53:04.117Z] HTTP Error: 403, The caller does not have permission
[2022-05-27T18:53:04.223Z] FirebaseError: HTTP Error: 403, The caller does not have permission
    at module.exports (/Users/dereekb/.nvm/versions/node/v16.13.2/lib/node_modules/firebase-tools/lib/responseToError.js:47:12)
    at RetryOperation._fn (/Users/dereekb/.nvm/versions/node/v16.13.2/lib/node_modules/firebase-tools/lib/apiv2.js:286:39)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

If I remove "prod" project:

{
  "projects": {
    "default": "dereekb-components"
  }
}

npx firebase hosting:channel:deploy test --debug

dereekb@dbMBP firebase-tools-default-issue % npx firebase hosting:channel:deploy test --debug
[2022-05-27T19:02:58.650Z] > 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-05-27T19:02:58.651Z] > authorizing via signed-in user (derek@hapiercreative.com)
[2022-05-27T19:02:58.651Z] [iam] checking project dereekb-components for permissions ["firebase.projects.get","firebasehosting.sites.update"]
[2022-05-27T19:02:58.652Z] >>> [apiv2][query] POST https://cloudresourcemanager.googleapis.com/v1/projects/dereekb-components:testIamPermissions [none]
[2022-05-27T19:02:58.652Z] >>> [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/dereekb-components:testIamPermissions {"permissions":["firebase.projects.get","firebasehosting.sites.update"]}
[2022-05-27T19:02:58.823Z] <<< [apiv2][status] POST https://cloudresourcemanager.googleapis.com/v1/projects/dereekb-components:testIamPermissions 200
[2022-05-27T19:02:58.823Z] <<< [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/dereekb-components:testIamPermissions {"permissions":["firebase.projects.get","firebasehosting.sites.update"]}
[2022-05-27T19:02:58.824Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/dereekb-components [none]
[2022-05-27T19:02:59.049Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/dereekb-components 200
[2022-05-27T19:02:59.050Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/dereekb-components {"projectId":"dereekb-components","projectNumber":"124286307516","displayName":"dereekb-components","name":"projects/dereekb-components","resources":{"hostingSite":"dereekb-components","realtimeDatabaseInstance":"dereekb-components-default-rtdb","storageBucket":"dereekb-components.appspot.com","locationId":"us-central"},"state":"ACTIVE"}
[2022-05-27T19:02:59.052Z] >>> [apiv2][query] GET https://firebasehosting.googleapis.com/v1beta1/projects/dereekb-components/sites/dereekb-components/channels/test [none]
[2022-05-27T19:02:59.264Z] <<< [apiv2][status] GET https://firebasehosting.googleapis.com/v1beta1/projects/dereekb-components/sites/dereekb-components/channels/test 200
[2022-05-27T19:02:59.264Z] <<< [apiv2][body] GET https://firebasehosting.googleapis.com/v1beta1/projects/dereekb-components/sites/dereekb-components/channels/test {"name":"projects/dereekb-components/sites/dereekb-components/channels/test","url":"https://dereekb-components--test-e8t1ab7i.web.app","createTime":"2022-05-27T18:44:55.672453201Z","updateTime":"2022-05-27T18:44:55.672453201Z","retainedReleaseCount":10,"expireTime":"2022-06-03T18:44:55.672453201Z"}
[2022-05-27T19:02:59.264Z] [hosting] found existing channel for site dereekb-components {"name":"projects/dereekb-components/sites/dereekb-components/channels/test","url":"https://dereekb-components--test-e8t1ab7i.web.app","createTime":"2022-05-27T18:44:55.672453201Z","updateTime":"2022-05-27T18:44:55.672453201Z","retainedReleaseCount":10,"expireTime":"2022-06-03T18:44:55.672453201Z"}
[2022-05-27T19:02:59.265Z] >>> [apiv2][query] PATCH https://firebasehosting.googleapis.com/v1beta1/projects/dereekb-components/sites/dereekb-components/channels/test updateMask=ttl
[2022-05-27T19:02:59.265Z] >>> [apiv2][body] PATCH https://firebasehosting.googleapis.com/v1beta1/projects/dereekb-components/sites/dereekb-components/channels/test {"ttl":"604800s"}
[2022-05-27T19:02:59.507Z] <<< [apiv2][status] PATCH https://firebasehosting.googleapis.com/v1beta1/projects/dereekb-components/sites/dereekb-components/channels/test 200
[2022-05-27T19:02:59.507Z] <<< [apiv2][body] PATCH https://firebasehosting.googleapis.com/v1beta1/projects/dereekb-components/sites/dereekb-components/channels/test {"name":"projects/dereekb-components/sites/dereekb-components/channels/test","url":"https://dereekb-components--test-e8t1ab7i.web.app","createTime":"2022-05-27T18:44:55.672453201Z","updateTime":"2022-05-27T19:02:59.462863149Z","retainedReleaseCount":10,"expireTime":"2022-06-03T19:02:59.462863149Z"}
[2022-05-27T19:02:59.507Z] [hosting] updated TTL for existing channel for site dereekb-components {"name":"projects/dereekb-components/sites/dereekb-components/channels/test","url":"https://dereekb-components--test-e8t1ab7i.web.app","createTime":"2022-05-27T18:44:55.672453201Z","updateTime":"2022-05-27T19:02:59.462863149Z","retainedReleaseCount":10,"expireTime":"2022-06-03T19:02:59.462863149Z"}

=== Deploying to 'dereekb-components'...

i  deploying hosting 
[2022-05-27T19:02:59.509Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/dereekb-components [none]
[2022-05-27T19:02:59.632Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/dereekb-components 200
[2022-05-27T19:02:59.632Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/dereekb-components {"projectId":"dereekb-components","projectNumber":"124286307516","displayName":"dereekb-components","name":"projects/dereekb-components","resources":{"hostingSite":"dereekb-components","realtimeDatabaseInstance":"dereekb-components-default-rtdb","storageBucket":"dereekb-components.appspot.com","locationId":"us-central"},"state":"ACTIVE"}
[2022-05-27T19:02:59.634Z] >>> [apiv2][query] POST https://firebasehosting.googleapis.com/v1beta1/projects/124286307516/sites/dereekb-components/versions [none]
[2022-05-27T19:02:59.634Z] >>> [apiv2][body] POST https://firebasehosting.googleapis.com/v1beta1/projects/124286307516/sites/dereekb-components/versions {"config":{},"labels":{"deployment-tool":"cli-firebase"}}
^C
dereekb@dbMBP firebase-tools-default-issue % 

The deploy goes through and uses the default.

[REQUIRED] Expected behavior

The Firebase CLI will use the default project by default, unless default doesn't exist. This would let projects that must strictly define default to use it.

This behavior mainly shows up in Docker containers, where you are opening up fresh contexts where firebase use isn't used.

[REQUIRED] Actual behavior

Previously working CI fails:

https://app.circleci.com/pipelines/github/dereekb/dbx-components/607/workflows/8b52bf87-f0c2-4f24-964a-bf9094d1d558/jobs/1359/parallel-runs/0/steps/0-105

@kyoshino
Copy link

kyoshino commented Sep 13, 2022

This just happned to us. We added the prodution project, then GitHub Actions failed to deploy the default (staging) project. Specifying --project=default is a workaround as the issue reporter said.

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

No branches or pull requests

4 participants