aws-cloudformation / cfn-lint

CloudFormation Linter
MIT No Attribution
2.44k stars 592 forks source link

Mixed identation checks #2940

Open wieshka opened 11 months ago

wieshka commented 11 months ago

Is this feature request related to a new rule or cfn-lint capabilities?

No response

Describe the feature you'd like to request

Currently, if template file contains rather valid JSON, but with mixed use of identation, cfn-lint does not show that as an issue, whilst boto3/botocore validate_template call will fail.

Describe the solution you'd like

cfn-lint should be able to detect mixed identation use and advise on fixing.

Additional context

This was found whilst investigating https://github.com/Sceptre/sceptre/issues/1311 where cfn-linst, jq, and python -mjson.tool was used to validate early JSON, but all of them yielded that template is valid. cfn-lint should represent the same outcome as would botocore/boto3 iniated create stack which validates template.

Is this something that you'd be interested in working on?

Would this feature include a breaking change?

kddejong commented 11 months ago

Can you provide a little more detail so I can reproduce the issue?

I've tried to make the template at https://github.com/Sceptre/sceptre/issues/1311#issuecomment-1791501335 code fail a few different ways (validate and create stack APIs) and I haven't been successful.

wieshka commented 11 months ago

Seems that there was some github handling in the sample of mixed identiation, try with this one: https://gist.githubusercontent.com/wieshka/91d37fe765b2a1189fb3d80dff71f9ed/raw/33f1153c9d05ac2ef290d5187f203de38e1bf725/sample.json

kddejong commented 11 months ago

So downloaded that file and then ran aws cloudformation validate-template --template-body file://\~/Downloads/sample.json and got no errors. You said you are using boto3/botocore so you are just hitting the APIs directly. I can try that too.