Skip to content

Commit 73733fd

Browse files
authored
Improve errors with invalid yaml files (#2589)
Fixes: #1718
1 parent 0e672f0 commit 73733fd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ansiblelint/utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ def get_action_tasks(data: AnsibleBaseYAMLObject, file: Lintable) -> list[Any]:
702702
@lru_cache(maxsize=None)
703703
def parse_yaml_linenumbers( # noqa: max-complexity: 12
704704
lintable: Lintable,
705-
) -> AnsibleBaseYAMLObject | AnsibleBaseYAMLObject:
705+
) -> AnsibleBaseYAMLObject:
706706
"""Parse yaml as ansible.utils.parse_yaml but with linenumbers.
707707
708708
The line numbers are stored in each node's LINE_NUMBER_KEY key.
@@ -746,7 +746,11 @@ def construct_mapping(
746746
if data is None:
747747
break
748748
result.append(data)
749-
except (yaml.parser.ParserError, yaml.scanner.ScannerError) as exc:
749+
except (
750+
yaml.parser.ParserError,
751+
yaml.scanner.ScannerError,
752+
yaml.constructor.ConstructorError,
753+
) as exc:
750754
raise RuntimeError("Failed to load YAML file") from exc
751755

752756
if len(result) == 0:

0 commit comments

Comments
 (0)