"amplifyPush --simple" results in "SyntaxError: Unexpected token b in JSON at position 0" error
See original GitHub issueNote: 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:
- Created 3 years ago
- Comments:8 (4 by maintainers)
I’ll transfer this issue over to Amplify Console repo so they can further help you should you run into this issue again.
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.