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

GetTemplate API does not support non-ASCII characters #1220

Open
idm-ryou opened this issue Jun 22, 2022 · 3 comments
Open

GetTemplate API does not support non-ASCII characters #1220

idm-ryou opened this issue Jun 22, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@idm-ryou
Copy link

idm-ryou commented Jun 22, 2022

Name of the resource

Other

Resource Name

CloudFormation GetTemplate API

Issue Description

When the GetTemplate API is executed against a stack of templates containing non-ASCII characters, such as Japanese characters, the non-ASCII characters in the template are converted to question marks.

This makes it impossible to properly understand the contents of the template after deployment, and also makes it impossible for tools such as AWS CDK to properly display the diff of the template.
aws/aws-cdk#10523

This is a big problem for non-English speakers, who often include native language descriptions and logs in their templates. This is also expected to be a problem for English speakers when specifying emojis.

Expected Behavior

Given

Deployed as SampleStack

Resources:
  MySNS:
    Type: AWS::SNS::Topic
    Properties: 
      DisplayName: Helloこんにちは☺

When

$  aws cloudformation get-template --stack-name SampleStack

Expected

{
    "TemplateBody": "Resources:\r\n  MySNS:\r\n    Type: AWS::SNS::Topic\r\n    Properties: \r\n      DisplayName: Helloこんにちは☺\r\n",
    "StagesAvailable": [
        "Original",
        "Processed"
    ]
}

Observed Behavior

Actual

{
    "TemplateBody": "Resources:\r\n  MySNS:\r\n    Type: AWS::SNS::Topic\r\n    Properties: \r\n      DisplayName: Hello??????\r\n",
    "StagesAvailable": [
        "Original",
        "Processed"
    ]
}

Test Cases

Deploy a CloudFormation template that contains non-ASCII characters and call the GetTemplate API to see if the same content is returned as the template.

Other Details

@azatoth
Copy link

azatoth commented Jul 27, 2022

@AidenAtSea I have problem to see how this can be seen as an enhancement and not as a bug. Could you expand on the rationale for this relabeling?

@kewur
Copy link

kewur commented Aug 11, 2022

related:

aws/aws-cdk#10523
aws/aws-cdk#20212

I agree that this is a bug and not an enhancement

mergify bot pushed a commit to aws/aws-cdk 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.
@tmokmss
Copy link

tmokmss commented Aug 29, 2024

This is now becoming a big problem because in Agents for Bedrock, it is very common to include non-ASCII characters as instruction or tools description of an agent (e.g. CJK languages; users want to define an agent with their native languages) in CloudFormation template (doc), and this issue makes CFn change set does not work properly. Even properties are unchanged, CFn changeset regards them as diffs, thereby making CDK diff unusable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants