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

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

Open
markdchurchill opened this issue Apr 11, 2024 · 2 comments
Labels
bug This issue is a bug. cli Issues related to the CDK CLI p2 package/tools Related to AWS CDK Tools or CLI

Comments

@markdchurchill
Copy link

markdchurchill commented Apr 11, 2024

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

@markdchurchill markdchurchill added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 11, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Apr 11, 2024
@pahud
Copy link
Contributor

pahud commented Apr 12, 2024

Pull the template json from the console, edit it, add a byte-order-mark, and update the stack

This seems to be an edge case. Can you explain why you need to do this?

@pahud pahud added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. cli Issues related to the CDK CLI and removed needs-triage This issue or PR still needs to be triaged. labels Apr 12, 2024
@markdchurchill
Copy link
Author

Obviously the BOM isn't being added intentionally - but editors will do this to files. If this is valid CF then cdk should work with it - if it is not valid CF then the console should reject it. At minimum cdk should produce accurate error messages.

This won't catch me out again, but others might not be so lucky to spot the issue.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Apr 13, 2024
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. cli Issues related to the CDK CLI p2 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests

2 participants