amplify-cli: JSON Parser error in Amplify
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
Amplify gives JSON parser error when we deploy the code to new AWS account other than the one thats currently running by just changing deployment option.
Amplify CLI Version
You can use amplify -v
to check the amplify cli version on your system
4.30.0
To Reproduce
Steps to reproduce the behavior or terminal output if applicable
- Create amplify project with REST API/LAMBDA, GRAPH QL, also has auth functionality.
- Deploy it an AWS account with Git based deployment.
- Deploy (amplify push) the app to another AWS account by choosing S3 and Cloudfront as hosting option. Expected behavior A clear and concise description of what you expected to happen. It is expected to deploy without any issues but got below error.
ERROR
✖ An error occurred when pushing the resources to the cloud Unexpected token u in JSON at position 0 An error occurred during the push operation: Unexpected token u in JSON at position 0
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [e.g. Mac/Windows/Ubuntu] Mac OS Catalina
- Node Version. You can use
node -v
to check the node version on your system v14.8.0
Additional context Add any other context about the problem here. The error is so cryptic that it does not say which JSON the issue occurred.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 37 (11 by maintainers)
Commits related to this issue
- fix: #6097 - don't create build folder during dryrun (#6133) — committed to aws-amplify/amplify-cli by deleted user 4 years ago
- fix: #6097 - check for root stack when loading projects for sanity check (#6121) — committed to aws-amplify/amplify-cli by deleted user 4 years ago
Thanks @matansagee for the troubleshooting, I was able to track down the bug and create the #6133 PR for it.
This issues happens in a rare constellation came with some recent changes. After we merge both PRs regarding this issue, the build pipelines could be unblocked, until then, developer machines can be used to do manual deployment.
The root cause is that Amplify Console CI/CD is doing a pull and a init+pull call during the Build step and pull now involves running code generation for DataStore enabled GraphQL APIs which causes the issue by creating the
build
folder and then normal push will not generate the required artifacts for deployment.@vrebo it’s in this path -
amplify/backend/api/API_NAME/build/cloudformation-template.json
the file iscloudformation-template.json
If you don’t have it there - run
amplify api gql-compile
Hi @PeteDuncanson! I was able to solve this issue with the assistance of @attilah .
What you should do is download the
#current-cloud-backend.zip
file from your S3 bucket. Add to this folder thecloudformation-template.json
file you have under#current-cloud-backend/api/<api name>/build
. Zip it again and upload it to S3 bucket.After that the
amplify push
should work. Please let me know if that helped you.so im on the latest cli an am running into this after creating an app and dev backend with the cli, and then added additional environments in the console, and then checked them out via cli - because apparently multienv is a touchy thing with the previous version. (4.37) now, with .38, I am getting this error when running amplify push -
'jsonString' argument missing or empty An error occurred during the push operation: 'jsonString' argument missing or empty
@attilah thanks for looking into this.
Last good push I made was yesterday on v4.37.1 from my developer machine.
Currently have v4.38 installed. I can confirm that when pushing I don’t have the
cloudformation-template.json
file in my build folder. Infact the only thing I do have is aparameters.json
file that is it.I’m all for getting to the bottom of the cause so keep your queries coming and I’ll answer as fast as I can. If you want to do a screen share or similar let me know.
Hi @attilah !
I was able to debug this issue more. Here are some screenshots.
Should all the files that are in
amplify/backend/api/event/build
be also in#current-cloud-backend/api/event/build
?It happens to me also when using other commands relates to
amplify api
I added a print of the file name that is failing.