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

"Unexpected end of JSON input" error in Diff stage #497

Closed
6 tasks
nagmesh opened this issue Jun 26, 2024 · 1 comment
Closed
6 tasks

"Unexpected end of JSON input" error in Diff stage #497

nagmesh opened this issue Jun 26, 2024 · 1 comment
Labels
bug Something isn't working pending-release This issue will be resolved in an upcoming release

Comments

@nagmesh
Copy link
Contributor

nagmesh commented Jun 26, 2024

Describe the bug
A clear and concise description of what the bug is.

When pipeline is run, Diff stage fails with

$ /codebuild/output/src1529/src/s3/00/source/packages/@aws-accelerator/accelerator/node_modules/.bin/ts-node --transpile-only cdk.ts --require-approval never diff --config-dir /codebuild/output/src1529/src/s3/01 --partition aws --app cdk.out --stage operations
....
2024-05-30 03:29:22.642 | info | replacements-config | Loading replacements config substitution values
Unexpected end of JSON input
error Command failed with exit code 1.

To Reproduce
Steps to reproduce the behavior.
Have one of the LZA stacks in stuck status like REVIEW_IN_PROGRESS, UPDATE_ROLLBACK_FAILED, etc so that GetTemplate response is empty string

Expected behavior
A clear and concise description of what you expected to happen.
Engine should know the response is non JSON and take an empty JSON for comparison.

Please complete the following information about the solution:

  • Version: [e.g. v1.5.1] 1.7.1

To get the version of the solution, you can look at the description of the created AWS CloudFormation stack used to install the LZA (AWSAccelerator-InstallerStack). For example, "(SO0199) Landing Zone Accelerator on AWS. Version 1.5.1.". If the description does not contain the version information, you can look at the Parameters of the stack for the RepositoryBranchName as that should contain the version number.

  • Region: [e.g. us-east-1] any region
  • Was the solution modified from the version published on this repository? No
  • If the answer to the previous question was yes, are the changes available on GitHub?
  • Have you checked your service quotas for the services this solution uses? Yes
  • Were there any errors in the CloudWatch Logs? Yes, posted above in issue

Screenshots
If applicable, add screenshots to help explain your problem (please DO NOT include sensitive information).

Additional context
Add any other context about the problem here.

When the Landing Zone Accelerator on AWS (LZA) performs a diff operation, it compares the stacks generated by the synthesis process with the existing stacks in the account. To retrieve the existing stacks, the GetTemplate API call is executed. If this call returns an error, an empty JSON response is sent back. In certain cases, stacks may be in a REVIEW_IN_PROGRESS state, which does not generate an error but instead produces a non-JSON output (empty string). When this output is compared, it results in the Unexpected end of JSON input error. Below is an example of what is happening.

> cat tst.yaml
Resources:
  test:
    Type: AWS::CloudFormation::WaitConditionHandle%
> aws cloudformation create-change-set --stack-name test-cg-01 --template-body file://tst.yaml --change-set-name test-cg-01-01 --change-set-type CREATE
{
    "Id": "arn:aws:cloudformation:eu-west-2:redacted:changeSet/test-cg-01-01/3e85e1aa-ac4a-4054-813e-8c3700e45d5d",
    "StackId": "arn:aws:cloudformation:eu-west-2:redacted:stack/test-cg-01/89c18d60-2286-11ef-82b6-0a425d4ba34f"
}
> aws cloudformation describe-stacks --stack-name test-cg-01 --query 'Stacks[0].StackStatus'
"REVIEW_IN_PROGRESS"
> aws cloudformation get-template --stack-name test-cg-01
{
    "TemplateBody": ""
}

If this error persists, it is recommended to check for stacks in the REVIEW_IN_PROGRESS state and delete them. These stacks are not fully created, and deleting them will not cause any service disruption.

@nagmesh nagmesh added bug Something isn't working pending-release This issue will be resolved in an upcoming release labels Jun 26, 2024
@nagmesh nagmesh changed the title "Unexpected end of JSON input" error "Unexpected end of JSON input" error in Diff stage Jun 26, 2024
@johnraws
Copy link
Contributor

Closing this issue as it is resolved in release/v1.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending-release This issue will be resolved in an upcoming release
Projects
None yet
Development

No branches or pull requests

2 participants