Skip to content

Commit

Permalink
Merge pull request #11962 from marcusburghardt/improve_yaml_processing
Browse files Browse the repository at this point in the history
Improve error handling when loading yaml stream
  • Loading branch information
jan-cerny authored May 9, 2024
2 parents 7ef2387 + 47b5c3b commit a8f8434
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ssg/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,16 @@ def construct_mapping(loader, node):
OrderedLoader.add_constructor(
yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
construct_mapping)
return yaml.load(stream, OrderedLoader)

try:
yaml_loaded = yaml.load(stream, OrderedLoader)
except yaml.scanner.ScannerError as e:
print("Error when trying to load the stream: {}".format(e))
print("HINT: Ansible tasks names may cause expansion errors if not properly quoted.")
print("HINT: Check for unquoted colons or other special symbols in the stream:")
print("{}".format(stream))
sys.exit(1)
return yaml_loaded


def ordered_dump(data, stream=None, Dumper=yaml_Dumper, **kwds):
Expand Down

0 comments on commit a8f8434

Please sign in to comment.