aws / aws/aws-cdk

deploy: byte-order-mark (BOM) in existing cf template causes YAMLSyntaxError and fails deployment

Open
#29,792 2 comments 0 reactions 0 assignees View on GitHub
bug cli p2 package/tools
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

When performing manual tweaks to stacks in the console (eg - migrating resources into nested) users can provide a template that starts with a byte-order-mark and this is accepted by the console.

On subsequent deployments using CDK this causes a deployment failure. Updating the stack in console to remove the BOM fixes the issue.

### Expected Behavior

aws-cdk should not have different behaviour to the console upload

### Current Behavior

```
XXXXXXXX: deploying... [1/1]
❌ XXXXXXXXX failed: YAMLSyntaxError: All collection items must start at the same column
at _Collection.parse (/usr/lib/node_modules/aws-cdk/lib/index.js:401:9191)
at /usr/lib/node_modules/aws-cdk/lib/index.js:401:28601
at _Document.parseContents (/usr/lib/node_modules/aws-cdk/lib/index.js:401:13915)
at _Document.parse (/usr/lib/node_modules/aws-cdk/lib/index.js:401:14863)
at Object.parse2 [as parse] (/usr/lib/node_modules/aws-cdk/lib/index.js:401:31141)
at parseDocument (/usr/lib/node_modules/aws-cdk/lib/index.js:423:9258)
at Object.parse2 (/usr/lib/node_modules/aws-cdk/lib/index.js:423:9537)
at parseYamlStrWithCfnTags (/usr/lib/node_modules/aws-cdk/lib/index.js:423:12316)
at deserialize (/usr/lib/node_modules/aws-cdk/lib/index.js:423:1[1915](https://gitlab.XXXXXXXXXXXX))
at deserializeStructure (/usr/lib/node_modules/aws-cdk/lib/index.js:423:12857) {
source: [_Collection]
}
```

### Reproduction Steps

- Deploy a simple stack with aws-cdk
- Pull the template json from the console, edit it, add a byte-order-mark, and update the stack
- Attempt to deploy against that stack with aws-cdk

### Possible Solution

_No response_

### Additional Information/Context

Important to note that all manual work was done in json, so I assume the yaml error was part of an internal process.

### CDK CLI Version

2.136.0 (build 94fd33b)

### Framework Version

_No response_

### Node.js Version

v18.20.1

### OS

Debian 12

### Language

.NET

### Language Version

8.0.203

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the deployment path around parseYamlStrWithCfnTags and deserialize shown in the stack trace, then reproduce the issue by adding a byte-order mark to a deployed template and running a CDK deployment. Done means a template containing a BOM is accepted consistently with the console upload instead of failing with YAMLSyntaxError.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.