firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.02k stars 936 forks source link

firebase deploy --only functions:x => TypeError: Cannot convert undefined or null to object #7585

Closed NigelThorne closed 2 months ago

NigelThorne commented 2 months ago

[REQUIRED] Environment info

firebase-tools: Version: 13.15.3

Platform: Ubuntu

[REQUIRED] Test case

[REQUIRED] Steps to reproduce

firebase deploy --only functions:x

[REQUIRED] Expected behavior

"Deploy complete!"

[REQUIRED] Actual behavior

✔  extensions: required API firebaseextensions.googleapis.com is enabled
[2024-08-23T03:27:01.408Z] > 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"]
[2024-08-23T03:27:01.408Z] > authorizing via signed-in user (nigel@xxxxx)
[2024-08-23T03:27:01.408Z] [iam] checking project xxx for permissions ["firebase.projects.get","firebaseextensions.instances.list"]
[2024-08-23T03:27:01.408Z] >>> [apiv2][query] POST https://cloudresourcemanager.googleapis.com/v1/projects/xxx:testIamPermissions [none]
[2024-08-23T03:27:01.408Z] >>> [apiv2][(partial)header] POST https://cloudresourcemanager.googleapis.com/v1/projects/xxx:testIamPermissions x-goog-quota-user=projects/xxx
[2024-08-23T03:27:01.408Z] >>> [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/xxx:testIamPermissions {"permissions":["firebase.projects.get","firebaseextensions.instances.list"]}
[2024-08-23T03:27:02.451Z] <<< [apiv2][status] POST https://cloudresourcemanager.googleapis.com/v1/projects/xxx:testIamPermissions 200
[2024-08-23T03:27:02.451Z] <<< [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/xxx:testIamPermissions {"permissions":["firebase.projects.get","firebaseextensions.instances.list"]}
[2024-08-23T03:27:02.656Z] TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at Object.want (/home/nigel/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/deploy/extensions/planner.js:120:28)
    at prepareDynamicExtensions (/home/nigel/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/deploy/extensions/prepare.js:122:48)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async prepare (/home/nigel/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/deploy/functions/prepare.js:62:9)
    at async chain (/home/nigel/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/deploy/index.js:40:9)
    at async deploy (/home/nigel/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/deploy/index.js:97:5)

Error: An unexpected error has occurred.


If I change extensions\planner.js so it handled args and args.extensions being null...

exports.wantDynamic = wantDynamic;
async function want(args) {
    const instanceSpecs = [];
    const errors = [];
    for (const e of Object.entries(args?.extensions ?? {})) {  # <--- deal with null

the command works.

NigelThorne commented 2 months ago

OK I think I worked out what's going on. I have a function called "externalApi" some code somewhere is assuming that because I have a function that start with "ext" I have extensions installed... then it freaks out when I don't have any and it gets an "undefined" back in args.extensions.

aalej commented 2 months ago

Hey @NigelThorne, thanks for reaching out to us. It looks like the issue you’re encountering is a duplicate of #7575. Currently, you could try downgrading to firebase-tools v13.15.2 to workaround the issue or upgrading to v13.15.4.

Do note however this issue #7582 on v13.15.4 where if don’t have an extension defined in your firebase.json, it would get deleted if you pass the --force flag.