Skip to content

Commit

Permalink
fix(cli): failure to load malformed YAML is swallowed (#19338)
Browse files Browse the repository at this point in the history
For some reason, we are falling back to reading JSON when loading YAML fails.

Since YAML is a superset of JSON, the only reason errors would occur because the YAML is not valid, in which case we shouldn't do this catch at all.

Fixes #19335.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr committed Mar 11, 2022
1 parent 1bc5144 commit 1875c28
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions packages/aws-cdk/lib/serialize.ts
Expand Up @@ -12,12 +12,7 @@ export function toYAML(obj: any): string {
* Parse either YAML or JSON
*/
export function deserializeStructure(str: string): any {
try {
return yaml_cfn.deserialize(str);
} catch (e) {
// This shouldn't really ever happen I think, but it's the code we had so I'm leaving it.
return JSON.parse(str);
}
return yaml_cfn.deserialize(str);
}

/**
Expand Down

0 comments on commit 1875c28

Please sign in to comment.