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

Error: Unexpected token : in JSON at position 19 at provider.request.then.catch #78

Closed
El-Fitz opened this issue Jul 17, 2017 · 11 comments · Fixed by #121
Closed

Error: Unexpected token : in JSON at position 19 at provider.request.then.catch #78

El-Fitz opened this issue Jul 17, 2017 · 11 comments · Fixed by #121
Labels

Comments

@El-Fitz
Copy link

El-Fitz commented Jul 17, 2017

This is a Bug Report

Description

  • What went wrong?
    The deployment failed on a cryptic error looking a lot like Unexpected token : in JSON during deploy #59. But my index.js is at the project's root, so I guess it's not the same issue ? The serverless.yml and index.js are attached.

  • What did you expect should have happened?
    The functions to be deployed

  • What was the config you used?
    Meaning ?

Similar or dependent issues:

Additional Data

  • Serverless Framework Version you're using: 1.17.0 (google-cloudfunctions 1.1.1)
  • Operating System: macOS 10.12.5
  • Stack Trace:
SLS_DEBUG=* sls deploy
Serverless: Packaging service...
Serverless: Compiling function "getTellUsForUser"...
Serverless: Compiling function "postTellUsVote"...
Serverless: Uploading artifacts...
Serverless: Artifacts successfully uploaded...
Serverless: Updating deployment...
Serverless: Checking deployment update progress...

  Error --------------------------------------------------

  Unexpected token : in JSON at position 19

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

Error: Unexpected token : in JSON at position 19
    at provider.request.then.catch (/Users/elfitz/Documents/Projects/MDE/WebServices/serverlessMDE/node_modules/serverless-google-cloudfunctions/shared/monitorDeployment.js:51:24)
From previous event:
    at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:217:22)
    at PluginManager.run (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:236:17)
    at variables.populateService.then (/usr/local/lib/node_modules/serverless/lib/Serverless.js:107:33)
    at runCallback (timers.js:800:20)
    at tryOnImmediate (timers.js:762:5)
    at processImmediate [as _immediateCallback] (timers.js:733:5)
From previous event:
    at Serverless.run (/usr/local/lib/node_modules/serverless/lib/Serverless.js:94:74)
    at serverless.init.then (/usr/local/lib/node_modules/serverless/bin/serverless:32:50)
    at <anonymous>

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Forums:        forum.serverless.com
     Chat:          gitter.im/serverless/serverless

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           8.1.4
     Serverless Version:     1.17.0

serverless.yml.zip
index.js.zip

@pmuens pmuens added the bug label Jul 18, 2017
@pmuens
Copy link
Contributor

pmuens commented Jul 18, 2017

🤔 Thanks for opening @El-Fitz 👍

Just looked at the code and nothing looks suspicious.

Are you able to see the error message the deployment manager returns in that case (maybe there are logs for the deployment manager in GCloud?).

@El-Fitz
Copy link
Author

El-Fitz commented Jul 18, 2017

No such thing :'(
Strange enough, I now have an App Engine App created and two Compute Engines initialized in the top right notifications. But I can't find them anywhere, and I didn't ask for them.

But maybe it's normal, has nothing to do with serverless and everything to do with me being used to aws and not GCloud (but I don't have a choice here)

Any idea on how / where I could intercept said error message ?

@pmuens
Copy link
Contributor

pmuens commented Jul 19, 2017

Thanks for the reply @El-Fitz 👍

🤔 that sounds really strange. Maybe it's really smth. on Googles end since Cloud Functions is still in beta.

@jtslear was able to retrieve some debug / log information (he described it here: #73 (comment)) Maybe you can do the same for this situation?!

@jakecoppinger
Copy link

I'm having the exact same issue too with an identical stack trace. I also came across #59 at first and then found this after making sure my entry point is at root.

I'm very new to Serverless but if I can do something to help let me know.

@El-Fitz
Copy link
Author

El-Fitz commented Jul 27, 2017

Hey ! @pmuens Sorry for the delay, I was asked to work on something else
Anyway, I managed to find these two errors in the deployment manager :

"/httpsTrigger/url": domain: validation; keyword: type; message: instance does not match any allowed primitive type; allowed: ["string"]; found: "object"

"/httpsTrigger/url": domain: validation; keyword: type; message: instance does not match any allowed primitive type; allowed: ["string"]; found: "object"

I'll also look into it on my side

@El-Fitz
Copy link
Author

El-Fitz commented Jul 27, 2017

So, that was it. I rewrote my functions http events from

- http:
          path: path/to/{id}/property
          method: post

to
- http: path/to/{id}/property

And it now deploys correctly :-) But it means we can't specify the method :'(

@El-Fitz
Copy link
Author

El-Fitz commented Jul 27, 2017

To be honest, I find GCP functions to be a real pain with it's handlers, modules and require handling. But I'll open something else for this :-)

@pmuens
Copy link
Contributor

pmuens commented Jul 27, 2017

Thanks for looking into this @El-Fitz 👍

Thanks for sharing the solution! That makes sense!

But it means we can't specify the method :'(

AFAIK GCF creates a feature rich API endpoint for you. So you should be able to use different methods and don't need to specify what method you want to create (at least that's how it got started AFAIK).

But I'll open something else for this :-)

Sound good! Looking forward to it 👍

@PatrickHeneise
Copy link
Contributor

Fixing this breaks sls run

Failed to configure the Event Gateway. Failed to configure the Event Gateway. Failed to subscribe the event http to the function vessels-list due the error: Subscription doesn't validate. Validation error: "Missing required fields (method, path) for HTTP event."

@Xplouder
Copy link

Xplouder commented Aug 12, 2018

Any update on this? Sounds like an old breaking bug.

@pickypg
Copy link
Contributor

pickypg commented Sep 27, 2018

This happened to me and I was able to run with SLS_DEBUG=*. It turns out that not all responses are valid JSON coming back from GCP, which is the root cause of this error. I pushed a fix with #121.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants