Skip to content

Commit a56adbe

Browse files
committed
Fix Unexpected token : in JSON
This fixes a bug where the deployment itself was legitimately failing, but the error handling itself failed. Specifically, I noticed that the error being thrown was unnecessarily hiding the actual error, which obfuscated the real issue. The real issue was that the error message was expected to return valid JSON, but it was pseudo-JSON instead (no surrounding `{}`). By removing the redundant JSON.stringify(JSON.parse(...)) wrapping of the message I was able to see the actual issue in my case: > "/httpsTrigger/url": domain: validation; keyword: type; message: instance does not match any allowed primitive type; allowed: ["string"]; found: "object" which allowed me to realize that what I had done in the past with AWS Lambda was not valid for GCP Cloud Functions (specifically specifying the HTTP event with a method and cors support).
1 parent 1e8dbb1 commit a56adbe

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

shared/monitorDeployment.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports = {
4848
return callback();
4949
})
5050
.catch((error) => {
51-
reject(new Error(error.message));
51+
reject(error);
5252
});
5353
}, frequency);
5454
},
@@ -66,8 +66,7 @@ module.exports = {
6666
const throwErrorIfDeploymentFails = (deployment) => {
6767
if (deployment.operation.error && deployment.operation.error.errors.length) {
6868
const errorCode = deployment.operation.error.errors[0].code;
69-
const parsedMessage = JSON.parse(deployment.operation.error.errors[0].message);
70-
const parsedDetails = JSON.stringify(parsedMessage);
69+
const parsedDetails = deployment.operation.error.errors[0].message;
7170
const errorMessage = [
7271
`Deployment failed: ${errorCode}\n\n`,
7372
` ${parsedDetails}`,

0 commit comments

Comments
 (0)