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

diff: cdk diff does not handle non-latin characters correctly #22203

Closed
igormukhin opened this issue Sep 23, 2022 · 2 comments · Fixed by #25912
Closed

diff: cdk diff does not handle non-latin characters correctly #22203

igormukhin opened this issue Sep 23, 2022 · 2 comments · Fixed by #25912
Labels
bug This issue is a bug. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. package/tools Related to AWS CDK Tools or CLI

Comments

@igormukhin
Copy link

Describe the bug

If the deployed version of your CF template has non-latin characters in it, the cdk diff does not understand those characters.

Expected Behavior

cdk diff should correctly handle non-latin characters in the deployed version of CF template.

Current Behavior

non-latic characters in the deployed version of CF template are seen as question marks ?.

Reproduction Steps

Use:

const app = new cdk.App();
const bugStack = new Stack(app, 'non-latin-in-diff-bug');
new secMan.Secret(bugStack, 'secret', {
    secretName: 'secret',
    description: 'привет öäüß',
});

Run: cdk deploy non-latin-in-diff-bug
Then run: cdk diff non-latin-in-diff-bug

The output will be:

Stack non-latin-in-diff-bug
Resources
[~] AWS::SecretsManager::Secret secret secret4DA88516 
 └─ [~] Description
     ├─ [-] ?????? ????
     └─ [+] привет öäüß

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.43.0 (build 487870a)

Framework Version

2.43.0

Node.js Version

v16.15.1

OS

Windows 10

Language

Typescript

Language Version

4.8.3

Other information

No response

@igormukhin igormukhin added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 23, 2022
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Sep 23, 2022
@peterwoodworth
Copy link
Contributor

I'm pretty certain that unfortunately, CloudFormation's GetTemplate API call, which we utilize under the hood to make diff possible, messes up certain characters in a way that is non recoverable, and there's nothing we can do about it. This may be something you will want to report in the CloudFormation Coverage Roadmap

@peterwoodworth peterwoodworth added needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. and removed needs-triage This issue or PR still needs to be triaged. labels Sep 27, 2022
@rix0rrr rix0rrr removed their assignment Jan 6, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

mergify bot pushed a commit that referenced this issue Jun 15, 2023
I am reopening this from #25525

and following up on my comments here:
#24557 (comment)
#24557 (comment)
#25008 (comment)
#25008 (comment)
#25008 (comment)
#25008 (comment)
#25008 (comment)
#25008 (comment)
#25525 (comment)
#25525 (comment)
🫠 #25525 (comment) 🫠

---

Fixes #25309
Fixes #22203
Fixes #20212
Fixes #13634
Fixes #10523
Fixes #10219
See also: aws-cloudformation/cloudformation-coverage-roadmap#1220
See also: aws-cloudformation/cloudformation-coverage-roadmap#814

---

👻 I have retitled this PR as a `chore` instead of a `fix` because @aws-cdk-automation keeps closing my PRs as abandoned even though they are clearly not abandoned.

> This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.

---

@otaviomacedo @rix0rrr @TheRealAmazonKendra - I'm happy to adjust the approach, add more tests, or do what else needs to be done. I'm not getting any feedback from the team so I'm not sure how to proceed. The diff noise with non-ASCII information in cdk diff makes it difficult to find meaningful changes to our stacks.

🗿🗞️📬 **Crucially, this change only affects the CLI output and therefore an integration test isn't possible.**

---

CloudFormation's `GetStackTemplate` irrecoverably mangles any character not in the 7-bit ASCII range. This causes noisy output from `cdk diff` when a template contains non-English languages or emoji. We can detect this case and consider these strings equal.

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*

Many AWS services accept non-ASCII input, eg many "description" fields. CloudFormation will correctly dispatch these templates but when invoking `GetStackTemplate` the result is mangled. This causes annoying noise in the output of `cdk diff`:

```
Resources
[~] AWS::Lambda::Function Lambda/Resource
 └─ [~] Description
     ├─ [-] ?????
     └─ [+] 🤦🏻‍♂️
```

This change modifies the diff algorithm to consider the string equal if the lvalue is a mangled version of the rvalue.

Of course this runs the risk of hiding changesets which modify only a single non-ASCII character to another non-ASCII character, but these fields already tend to be informative in nature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants