monken / cfn-include

Preprocessor for CloudFormation templates with support for loops and flexible include statements
MIT License
86 stars 10 forks source link

cfn-include doesn't fail on broken YAML template #28

Closed kika closed 7 years ago

kika commented 7 years ago

When cfn-include processes the following

  !Sub
    - "arn:aws:route53:::hostedzone/${ZoneId}/rrset" 
    - { ZoneId: !If [IsProd, "XYZ" "ZQW" ] }

(missing comma) it generates an exception

Unhandled rejection SyntaxError: YAMLException: missed comma between flow collection entries at line 1787, column 59:
     ... : !If [IsProd, "XYZ" "ZQW" ] }
                              ^,Error: unterminated Regular Expression literal

at index.js line 156:18.

BUT. It returns a zero status code to the calling process and thus allows the integration infrastructure to proceed.

I've fixed it quick and dirty by adding the following

process.on('unhandledRejection', function(reason, _promise) {
  console.error( "Internal error: ", reason );
  process.exit(1);
});

to cls.js after the line 48. But I'm not sure it's the way to go, let me know if this is acceptable and I'll make a PR.