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

Fix Unexpected token : in JSON #121

Merged
merged 1 commit into from
Oct 30, 2018
Merged

Fix Unexpected token : in JSON #121

merged 1 commit into from
Oct 30, 2018

Conversation

pickypg
Copy link
Contributor

@pickypg pickypg commented Sep 27, 2018

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).

Closes #78

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).
Copy link
Contributor

@pmuens pmuens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Thanks for fixing this @pickypg 👍

LGTM :shipit:

@pmuens pmuens merged commit 0a0d7c9 into serverless:master Oct 30, 2018
@pickypg pickypg deleted the fix/78 branch October 30, 2018 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: Unexpected token : in JSON at position 19 at provider.request.then.catch
2 participants