firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.01k stars 925 forks source link

Deploying Firebase functions breaks with `TypeError: Cannot read properties of undefined (reading 'service')` if the same project has non-Firebase v2 functions #5662

Closed icopp closed 1 year ago

icopp commented 1 year ago

[REQUIRED] Environment info

firebase-tools: 11.25.3

Platform: macOS

[REQUIRED] Test case

[REQUIRED] Steps to reproduce

[REQUIRED] Expected behavior

[REQUIRED] Actual behavior

[2023-04-05T19:26:51.509Z] >>> [apiv2][query] GET https://cloudfunctions.googleapis.com/v2/projects/project-id-here/locations/-/functions filter=environment%3D%22GEN_2%22
[2023-04-05T19:26:52.129Z] <<< [apiv2][status] GET https://cloudfunctions.googleapis.com/v2/projects/project-id-here/locations/-/functions 200
[2023-04-05T19:26:52.130Z] <<< [apiv2][body] GET https://cloudfunctions.googleapis.com/v2/projects/project-id-here/locations/-/functions {...big blob of JSON here...}
[2023-04-05T19:26:52.136Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-1 [none]
[2023-04-05T19:26:52.137Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-2 [none]
[2023-04-05T19:26:52.137Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-3 [none]
[2023-04-05T19:26:52.138Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-4 [none]
[2023-04-05T19:26:52.138Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-5 [none]
[2023-04-05T19:26:52.138Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-6 [none]
[2023-04-05T19:26:52.139Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-7 [none]
[2023-04-05T19:26:52.139Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-8 [none]
[2023-04-05T19:26:52.139Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-9 [none]
[2023-04-05T19:26:52.140Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-10 [none]
[2023-04-05T19:26:52.140Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-11 [none]
[2023-04-05T19:26:52.140Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-12 [none]
[2023-04-05T19:26:52.141Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-13 [none]
[2023-04-05T19:26:52.142Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-14 [none]
[2023-04-05T19:26:52.142Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v1-name-here-15 [none]
[2023-04-05T19:26:52.142Z] >>> [apiv2][query] GET https://run.googleapis.com/v1/projects/project-id-here/locations/us-central1/services/cloud-function-with-v2-name-here-1 [none]
[2023-04-05T19:26:52.144Z] TypeError: Cannot read properties of undefined (reading 'service')
    at /Users/username/.nvm/versions/node/v16.17.1/lib/node_modules/firebase-tools/lib/deploy/functions/backend.js:198:113
    at Array.map (<anonymous>)
    at loadExistingBackend (/Users/username/.nvm/versions/node/v16.17.1/lib/node_modules/firebase-tools/lib/deploy/functions/backend.js:198:69)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.existingBackend (/Users/username/.nvm/versions/node/v16.17.1/lib/node_modules/firebase-tools/lib/deploy/functions/backend.js:174:9)
    at async prepare (/Users/username/.nvm/versions/node/v16.17.1/lib/node_modules/firebase-tools/lib/deploy/functions/prepare.js:138:115)
    at async chain (/Users/username/.nvm/versions/node/v16.17.1/lib/node_modules/firebase-tools/lib/deploy/index.js:35:9)
    at async deploy (/Users/username/.nvm/versions/node/v16.17.1/lib/node_modules/firebase-tools/lib/deploy/index.js:79:5)
taeold commented 1 year ago

Thanks for the report @icopp. Going to mark this a duplicate of https://github.com/firebase/firebase-tools/issues/4800 and begin to find a way to address this issue asap.