From d900ef965b94895fc7f63665cd5a57d83333215d Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Thu, 10 Mar 2022 17:02:21 -0800 Subject: [PATCH] fix(cli): failure to load malformed YAML is swallowed 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. --- packages/aws-cdk/lib/serialize.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/aws-cdk/lib/serialize.ts b/packages/aws-cdk/lib/serialize.ts index 62a9bb70c3322..ea7ea30c3b89c 100644 --- a/packages/aws-cdk/lib/serialize.ts +++ b/packages/aws-cdk/lib/serialize.ts @@ -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); } /**