firebase / firebase/firebase-tools
firebase deploy should display more helpful error message when deployment fails due to error in user code
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 84
Description
### [REQUIRED] Environment info
**firebase-tools:** 11.16.1
**Platform:** Ubuntu
### [REQUIRED] Test case
package.json:
```
{
"name": "functions",
"scripts": {
"lint": "eslint --ext .js,.ts .",
"build": "tsc",
"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": {
"braintree": "^3.12.0",
"express": "^4.18.2",
"firebase-admin": "^11.3.0",
"firebase-functions": "^4.1.0"
},
"devDependencies": {
"@types/braintree": "^3.3.3",
"@types/express-serve-static-core": "^4.17.31",
"@typescript-eslint/eslint-plugin": "^5.6.0",
"@typescript-eslint/parser": "^5.6.0",
"eslint": "^7.6.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.22.0",
"firebase-functions-test": "^0.2.0",
"typescript": "^4.8"
},
"private": true
}
```
index.ts
```
import * as functions from 'firebase-functions';
import * as express from 'express';
import * as cors from 'cors';
import { initializeApp } from 'firebase-admin/app';
const app = express();
app.use(cors({ origin: true }));
app.get('/', (req, res) => res.sendStatus(200));
exports.app = functions.https.onRequest(app);
initializeApp();
```
### [REQUIRED] Steps to reproduce
This error appears since the initialization.
[REQUIRED] Expected behaviour
It should run without errors
### [REQUIRED] Actual behavior
The error hinders the deployment of the firebase functions
firebase-debug.log:
```
[debug] [2022-12-04T19:31:51.496Z] ----------------------------------------------------------------------
[debug] [2022-12-04T19:31:51.497Z] Command: /root/.nvm/versions/node/v16.18.1/bin/node /root/freelance/projects/my-project/node_modules/.bin/firebase --debug deploy
[debug] [2022-12-04T19:31:51.497Z] CLI Version: 11.16.1
[debug] [2022-12-04T19:31:51.497Z] Platform: linux
[debug] [2022-12-04T19:31:51.497Z] Node Version: v16.18.1
[debug] [2022-12-04T19:31:51.498Z] Time: Sun Dec 04 2022 20:31:51 GMT+0100 (Central European Standard Time)
[debug] [2022-12-04T19:31:51.498Z] ----------------------------------------------------------------------
[debug]
[debug] [2022-12-04T19:31:51.540Z] > 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"]
[debug] [2022-12-04T19:31:51.541Z] > authorizing via signed-in user (mail@gmail.com)
[debug] [2022-12-04T19:31:51.541Z] [iam] checking project my-project for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","datastore.indexes.create","datastore.indexes.delete","datastore.indexes.list","datastore.indexes.update","firebase.projects.get","firebasehosting.sites.update"]
[debug] [2022-12-04T19:31:51.542Z] >>> [apiv2][query] POST https://cloudresourcemanager.googleapis.com/v1/projects/my-project:testIamPermissions [none]
[debug] [2022-12-04T19:31:51.543Z] >>> [apiv2][(partial)header] POST https://cloudresourcemanager.googleapis.com/v1/projects/my-project:testIamPermissions x-goog-quota-user=projects/my-project
[debug] [2022-12-04T19:31:51.543Z] >>> [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/my-project:testIamPermissions {"permissions":["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","datastore.indexes.create","datastore.indexes.delete","datastore.indexes.list","datastore.indexes.update","firebase.projects.get","firebasehosting.sites.update"]}
[debug] [2022-12-04T19:31:51.790Z] <<< [apiv2][status] POST https://cloudresourcemanager.googleapis.com/v1/projects/my-project:testIamPermissions 200
[debug] [2022-12-04T19:31:51.790Z] <<< [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/my-project:testIamPermissions {"permissions":["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","datastore.indexes.create","datastore.indexes.delete","datastore.indexes.list","datastore.indexes.update","firebase.projects.get","firebasehosting.sites.update"]}
[debug] [2022-12-04T19:31:51.790Z] >>> [apiv2][query] POST https://iam.googleapis.com/v1/projects/my-project/serviceAccounts/my-project@appspot.gserviceaccount.com:testIamPermissions [none]
[debug] [2022-12-04T19:31:51.790Z] >>> [apiv2][body] POST https://iam.googleapis.com/v1/projects/my-project/serviceAccounts/my-project@appspot.gserviceaccount.com:testIamPermissions {"permissions":["iam.serviceAccounts.actAs"]}
[debug] [2022-12-04T19:31:52.427Z] <<< [apiv2][status] POST https://iam.googleapis.com/v1/projects/my-project/serviceAccounts/my-project@appspot.gserviceaccount.com:testIamPermissions 200
[debug] [2022-12-04T19:31:52.427Z] <<< [apiv2][body] POST https://iam.googleapis.com/v1/projects/my-project/serviceAccounts/my-project@appspot.gserviceaccount.com:testIamPermissions {"permissions":["iam.serviceAccounts.actAs"]}
[debug] [2022-12-04T19:31:52.428Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/my-project [none]
[debug] [2022-12-04T19:31:52.738Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/my-project 200
[debug] [2022-12-04T19:31:52.739Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/my-project {"projectId":"my-project","projectNumber":"699988849795","displayName":"my-project","name":"projects/my-project","resources":{"hostingSite":"my-project","realtimeDatabaseInstance":"my-project","storageBucket":"my-project.appspot.com","locationId":"us-central"},"state":"ACTIVE","etag":"1_519894af-2b25-4a61-8e82-5edb7e2a5435"}
[info]
[info] === Deploying to 'my-project'...
[info]
[info] i deploying firestore, functions, hosting
[info] ✔ functions: Finished running predeploy script.
[info] i firestore: reading indexes from firestore.indexes.json...
[info] i cloud.firestore: checking firestore.rules for compilation errors...
[debug] [2022-12-04T19:31:52.741Z] >>> [apiv2][query] POST https://firebaserules.googleapis.com/v1/projects/my-project:test [none]
[debug] [2022-12-04T19:31:52.741Z] >>> [apiv2][body] POST https://firebaserules.googleapis.com/v1/projects/my-project:test [omitted]
[debug] [2022-12-04T19:31:53.010Z] <<< [apiv2][status] POST https://firebaserules.googleapis.com/v1/projects/my-project:test 200
[debug] [2022-12-04T19:31:53.010Z] <<< [apiv2][body] POST https://firebaserules.googleapis.com/v1/projects/my-project:test {}
[info] ✔ cloud.firestore: rules file firestore.rules compiled successfully
[debug] [2022-12-04T19:31:53.011Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/my-project [none]
[debug] [2022-12-04T19:31:53.240Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/my-project 200
[debug] [2022-12-04T19:31:53.240Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/my-project {"projectId":"my-project","projectNumber":"699988849795","displayName":"my-project","name":"projects/my-project","resources":{"hostingSite":"my-project","realtimeDatabaseInstance":"my-project","storageBucket":"my-project.appspot.com","locationId":"us-central"},"state":"ACTIVE","etag":"1_519894af-2b25-4a61-8e82-5edb7e2a5435"}
[info] i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
[info] i functions: ensuring required API cloudbuild.googleapis.com is enabled...
[info] i artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
[debug] [2022-12-04T19:31:53.241Z] >>> [apiv2][query] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/cloudfunctions.googleapis.com [none]
[debug] [2022-12-04T19:31:53.241Z] >>> [apiv2][(partial)header] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/cloudfunctions.googleapis.com x-goog-quota-user=projects/my-project
[debug] [2022-12-04T19:31:53.242Z] >>> [apiv2][query] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/runtimeconfig.googleapis.com [none]
[debug] [2022-12-04T19:31:53.242Z] >>> [apiv2][(partial)header] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/runtimeconfig.googleapis.com x-goog-quota-user=projects/my-project
[debug] [2022-12-04T19:31:53.243Z] >>> [apiv2][query] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/cloudbuild.googleapis.com [none]
[debug] [2022-12-04T19:31:53.243Z] >>> [apiv2][(partial)header] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/cloudbuild.googleapis.com x-goog-quota-user=projects/my-project
[debug] [2022-12-04T19:31:53.243Z] >>> [apiv2][query] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/artifactregistry.googleapis.com [none]
[debug] [2022-12-04T19:31:53.243Z] >>> [apiv2][(partial)header] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/artifactregistry.googleapis.com x-goog-quota-user=projects/my-project
[debug] [2022-12-04T19:31:54.126Z] <<< [apiv2][status] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/cloudbuild.googleapis.com 200
[debug] [2022-12-04T19:31:54.126Z] <<< [apiv2][body] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/cloudbuild.googleapis.com [omitted]
[info] ✔ functions: required API cloudbuild.googleapis.com is enabled
[debug] [2022-12-04T19:31:54.127Z] <<< [apiv2][status] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/artifactregistry.googleapis.com 200
[debug] [2022-12-04T19:31:54.128Z] <<< [apiv2][body] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/artifactregistry.googleapis.com [omitted]
[info] ✔ artifactregistry: required API artifactregistry.googleapis.com is enabled
[debug] [2022-12-04T19:31:54.128Z] <<< [apiv2][status] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/runtimeconfig.googleapis.com 200
[debug] [2022-12-04T19:31:54.128Z] <<< [apiv2][body] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/runtimeconfig.googleapis.com [omitted]
[debug] [2022-12-04T19:31:54.129Z] <<< [apiv2][status] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/cloudfunctions.googleapis.com 200
[debug] [2022-12-04T19:31:54.129Z] <<< [apiv2][body] GET https://serviceusage.googleapis.com/v1/projects/my-project/services/cloudfunctions.googleapis.com [omitted]
[info] ✔ functions: required API cloudfunctions.googleapis.com is enabled
[info] i functions: preparing codebase default for deployment
[debug] [2022-12-04T19:31:55.280Z] Validating nodejs source
[warn] ⚠ functions: package.json indicates an outdated version of firebase-functions. Please upgrade using npm install --save firebase-functions@latest in your functions directory.
[warn] ⚠ functions: Please note that there will be breaking changes when you upgrade.
[debug] [2022-12-04T19:31:56.981Z] > [functions] package.json contents: {
"name": "functions",
"description": "Angular Universal Application",
"main": "index.js",
"scripts": {
"start": "firebase functions:shell"
},
"engines": {
"node": "16"
},
"dependencies": {
"firebase-admin": "^9.11.1",
"firebase-functions": "^3.6.0"
},
"devDependencies": {},
"private": true
}
[debug] [2022-12-04T19:31:56.981Z] Building nodejs source
[debug] [2022-12-04T19:31:56.982Z] Could not find functions.yaml. Must use http discovery
[debug] [2022-12-04T19:31:57.068Z] Serving at port 9005
[debug] [2022-12-04T19:31:57.075Z] Got response from /__/functions.yaml Failed to generate manifest from function source: SyntaxError: Invalid left-hand side in assignment
[debug] [2022-12-04T19:31:57.078Z] Failed to parse functions.yamlincomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line at line 1, column 62:
... rom function source: SyntaxError: Invalid left-hand side in assi ...
^ {"name":"YAMLException","reason":"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line","mark":{"name":null,"buffer":"Failed to generate manifest from function source: SyntaxError: Invalid left-hand side in assignment\n\u0000","position":61,"line":0,"column":61},"message":"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line at line 1, column 62:\n ... rom function source: SyntaxError: Invalid left-hand side in assi ... \n ^"}
[debug] [2022-12-04T19:31:57.081Z] shutdown requested via /__/quitquitquit
[error]
[error] Error: Failed to load function definition from source: Failed to generate manifest from function source: SyntaxError: Invalid left-hand side in assignment
```
I removed parts containing sensitive data
Contributor guide
Assessment
This issue has not been assessed yet.