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

JSON parse error inprintStackDiff leading to malformed diffs #597

Closed
6 tasks done
k7k0 opened this issue Oct 8, 2024 · 3 comments
Closed
6 tasks done

JSON parse error inprintStackDiff leading to malformed diffs #597

k7k0 opened this issue Oct 8, 2024 · 3 comments
Labels
bug Something isn't working pending-release This issue will be resolved in an upcoming release

Comments

@k7k0
Copy link
Contributor

k7k0 commented Oct 8, 2024

Describe the bug
When running a stack diff, the printStackDiff function is doing a JSON.stringify of newTemplate which is the template path, not the contents. Leading to diffs like this:

Stack: AWSAccelerator-NetworkAssociationsGwlbStack-<account>-<region>
Other Changes
[+] Unknown 270: l
[+] Unknown 271: a
[+] Unknown 272: t
[+] Unknown 273: e
[+] Unknown 274: .
[+] Unknown 275: j
[+] Unknown 276: s
[+] Unknown 277: o
[+] Unknown 278: n
[~] Unknown 266: j to t
[~] Unknown 267: s to e
[~] Unknown 268: o to m
[~] Unknown 269: n to 

instead it should do JSON.stringify(readTemplate(newTemplate)) to stringify the file contents and get the correct mangled version.

To Reproduce
Synth and diff a stage having differenceCount bigger than the number of letters of the .json path length.
For example, add a new region and a VPC, then

yarn ts-node --transpile-only cdk.ts --require-approval never --partition aws --stage network-associations --config-dir <config- dir> synth
yarn ts-node --transpile-only cdk.ts --require-approval never --partition aws --stage network-associations --config-dir <config-dir> diff

Expected behavior

Stack: AWSAccelerator-NetworkAssociationsGwlbStack-<account>-<region>
Template
[+] Description Description: (SO0199-networkgwlb) Landing Zone Accelerator on AWS. Version 1.9.2.

Parameters
[+] Parameter ###
....

Resources
[+] AWS::SSM::Parameter ###
[+] AWS::SSM::Parameter ###

Please complete the following information about the solution:

  • Version: 1.9.2
  • Region: any
  • 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? N/A
  • Were there any errors in the CloudWatch Logs? N/A
@k7k0 k7k0 added the bug Something isn't working label Oct 8, 2024
@richardkeit
Copy link
Contributor

Smart @k7k0!

Related issue:

@k7k0
Copy link
Contributor Author

k7k0 commented Oct 8, 2024

it looks like a regression introduced while upgrading to CDK 2.148.0.
image

readTemplate should be used for the fullDiff on next line as well

k7k0 added a commit to k7k0/landing-zone-accelerator-on-aws that referenced this issue Oct 8, 2024
@erwaxler erwaxler added the pending-release This issue will be resolved in an upcoming release label Oct 11, 2024
erwaxler pushed a commit that referenced this issue Oct 17, 2024
@richardkeit
Copy link
Contributor

@erwaxler - please mark as closed.
Thanks

rycerrat pushed a commit that referenced this issue Feb 18, 2025
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

Successfully merging a pull request may close this issue.

3 participants