Skip to content

[cli] cdk diff always reports diff if resource has non-ASCII characters #10523

@idm-ryou

Description

@idm-ryou

cdk diff always reports diff if resource has non-ASCII characters.

Reproduction Steps

import * as cdk from "@aws-cdk/core";
import * as codebuild from "@aws-cdk/aws-codebuild";

const app = new cdk.App();
const stack = new cdk.Stack(app, "stack1");
new codebuild.Project(stack, "FooProject", {
  buildSpec: codebuild.BuildSpec.fromObject({
    version: "0.2",
    phases: {
      build: {
        commands: ["echo こんにちは"], // "Hello" in Japanese
      },
    },
  }),
});
$ cdk --version
1.63.0 (build 7a68125)

$ cdk deploy stack1 --require-approval=never
stack1: deploying...
<snip>
 ✅  stack1

$ cdk diff stack1
Stack stack1
Resources
[~] AWS::CodeBuild::Project FooProject FooProject9FE653E4 
 └─ [~] Source
     └─ [~] .BuildSpec:
         ├─ [-] {
  "version": "0.2",
  "phases": {
    "build": {
      "commands": [
        "echo ?????"
      ]
    }
  }
}
         └─ [+] {
  "version": "0.2",
  "phases": {
    "build": {
      "commands": [
        "echo こんにちは"
      ]
    }
  }
}

What did you expect to happen?

cdk diff reports no diff, when resources are in sync.

What actually happened?

cdk diff always reports diff, even when resources are in sync.

Environment

  • CLI Version : 1.63.0
  • Framework Version: 1.63.0
  • Node.js Version: v12.18.4
  • OS : Linux (Docker container)
  • Language (Version): all (I guess...)

Other

Guessing from its behavior, it seems like correct encoding(UTF-8?) is not specified while fetching current template from CloudFormation. So that the non-ASCII characters are converted to the "?" character and treated as if it is having diffs.


This is 🐛 Bug Report

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedWork is blocked on this issue for this codebase. Other labels or comments may indicate why.bugThis issue is a bug.effort/mediumMedium work item – several days of effortneeds-cfnThis issue is waiting on changes to CloudFormation before it can be addressed.p1package/toolsRelated to AWS CDK Tools or CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions