question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"amplifyPush --simple" results in "SyntaxError: Unexpected token b in JSON at position 0" error

See original GitHub issue

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the Amplify Console GitHub Issue Tracker

Describe the bug “amplifyPush --simple” command in my pipeline results in “SyntaxError: Unexpected token b in JSON at position 0” error. This happens only when I let AWS Amplify Console build my backend, NOT when I run “amplify push” locally.

Amplify CLI Version 4.26.0

To Reproduce Issue happens when I run “git push”, and the AWS Amplify Console starts to run “amplifyPush --simple”.

backend:
  phases:
    build:
      commands:
        - amplify --version
        - amplifyPush --simple

Expected behavior Just like when doing a local “amplify push”, there should not be an error when pushing the resources to the cloud.

Screenshots This is the logs from the AWS Amplify Console. Looks like a JSON.parse issue at the amplifyUtils.ts file of graphql-transformer-core.

        # Starting phase: build
        # Executing command: amplify --version
[INFO]: 4.26.0
[INFO]: # Executing command: amplifyPush --simple
[INFO]: 
[INFO]: For more information on AWS Profiles, see:
        https://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html
[INFO]: Amplify AppID found: ... Amplify App name is: ...
[INFO]: Backend environment ... found in Amplify Console app: ...
[INFO]: 
[WARNING]: - Fetching updates to backend environment: ... from the cloud.
[WARNING]: ✔ Successfully pulled backend environment ... from the cloud.
[WARNING]: ✖ An error occurred when pushing the resources to the cloud
[WARNING]: ✖ There was an error initializing your environment.
[INFO]: Failed to pull the backend.
[INFO]: Unexpected token b in JSON at position 0
[INFO]: SyntaxError: Unexpected token b in JSON at position 0
        at JSON.parse (<anonymous>)
        at ensureMissingStackMappings (/root/.nvm/versions/node/v10.16.0/lib/node_modules/@aws-amplify/cli/node_modules/graphql-transformer-core/src/util/amplifyUtils.ts:150:40)
[ERROR]: !!! Build failed
[ERROR]: !!! Non-Zero Exit Code detected
[INFO]: # Starting environment caching...
[INFO]: # Uploading environment cache artifact...
[INFO]: # Environment caching completed
Terminating logging...

Desktop (please complete the following information):

  • OS: Mac
  • Node Version. v14.4.0

Additional context This happened twice, but on the third attempt, it worked. I did not make any changes to the graphql file. I just made changes to CHANGELOG and pushed just to trigger the pipeline.

[WARNING]: - Fetching updates to backend environment: ... from the cloud.
[WARNING]: ✔ Successfully pulled backend environment ... from the cloud.
[INFO]: GraphQL schema compiled successfully.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
SwaySwaycommented, Aug 6, 2020

I’ll transfer this issue over to Amplify Console repo so they can further help you should you run into this issue again.

0reactions
github-actions[bot]commented, May 25, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

simple" results in "SyntaxError: Unexpected token b in JSON ...
Describe the bug "amplifyPush --simple" command in my pipeline results in "SyntaxError: Unexpected token b in JSON at position 0" error.
Read more >
SyntaxError: Unexpected token < in JSON at position 0
Since it looks like the error seems to have something to do with pulling JSON data from the server, I tried starting from...
Read more >
'Unexpected token < in JSON at position 0' when enrolling ...
This error occurs when a Moodle page makes a background request to the server using XHR (sometimes called AJAX). The Moodle page expects...
Read more >
Unexpected token in JSON at position 0 - YouTube
Uncaught (in promise) SyntaxError : Unexpected token in JSON at position 0.
Read more >
How to Fix 'Unexpected token o in JSON at position 1' - Webtips
The error happens when JSON.parse gets an invalid JSON string. The reason this error message happens is that you try to pass an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found