diff --git a/swh/indexer/metadata_dictionary/base.py b/swh/indexer/metadata_dictionary/base.py index e992bb521468ed8482e22593abcfbf7493a958f3..e8fd8c2ea1c534e2c34ca862623aea542298c36b 100644 --- a/swh/indexer/metadata_dictionary/base.py +++ b/swh/indexer/metadata_dictionary/base.py @@ -400,7 +400,7 @@ class YamlMapping(DictMapping): raw_content_string: str = raw_content.decode() try: content_dict = yaml.load(raw_content_string, Loader=SafeLoader) - except (yaml.scanner.ScannerError, yaml.parser.ParserError): + except yaml.YAMLError: return None if isinstance(content_dict, dict): diff --git a/swh/indexer/tests/metadata_dictionary/test_dart.py b/swh/indexer/tests/metadata_dictionary/test_dart.py index 9dad26379bc5a8801ff9b15db4d836282f548269..0528615fedc9c4421df5d89b20f3d569eb0349a9 100644 --- a/swh/indexer/tests/metadata_dictionary/test_dart.py +++ b/swh/indexer/tests/metadata_dictionary/test_dart.py @@ -159,3 +159,14 @@ def test_invalid_yaml(): result = MAPPINGS["PubMapping"]().translate(raw_content) assert result is None + + +def test_invalid_tag(): + raw_content = b""" + name: translatron + description: !BETA VERSION - NOT FOR LIVE OR PROD USAGE! + """ + + result = MAPPINGS["PubMapping"]().translate(raw_content) + + assert result is None