Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error handling when loading yaml stream #11962

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading