awslabs / aws-cfn-template-flip

Tool for converting AWS CloudFormation templates between JSON and YAML formats.
Apache License 2.0
994 stars 142 forks source link

Incorrect error returned on YAML parsing error: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #105

Closed rychoo2 closed 3 years ago

rychoo2 commented 3 years ago

When parsing an incorrect yaml, the actual parsing error is not raised, only the previous misleading JSON error is returned instead:

Error Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cfn_flip/__init__.py", line 27, in load data = load_json(template) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/cfn_tools/__init__.py", line 20, in load_json return json.loads(source, object_pairs_hook=ODict) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py", line 370, in loads return cls(**kw).decode(s) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

See: https://github.com/awslabs/aws-cfn-template-flip/blob/5c4298eec9e45b3f5783a6fbea1c866a27ce8d4e/cfn_flip/__init__.py#L29-L34

I would expect to see the YAML parsing error.

koiker commented 3 years ago

Can you share the invalid Yaml document to add to the tests?

koiker commented 3 years ago

Closed due to inactivity.