Page MenuHomeSoftware Heritage

Jenkins > .tox.py3.lib.python3.7.site-packages.swh.indexer.tests.test_metadata.TestMetadata::test_npm_adversarial
Failed

TEST RESULT

Run At
Jun 16 2022, 10:04 AM
Details
self = <swh.indexer.tests.test_metadata.TestMetadata object at 0x7eff1204bda0> @settings(suppress_health_check=[HealthCheck.too_slow]) > @given(json_document_strategy(keys=list(NpmMapping.mapping))) def test_npm_adversarial(self, doc): .tox/py3/lib/python3.7/site-packages/swh/indexer/tests/test_metadata.py:1114: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox/py3/lib/python3.7/site-packages/swh/indexer/tests/test_metadata.py:1117: in test_npm_adversarial self.npm_mapping.translate(raw) .tox/py3/lib/python3.7/site-packages/swh/indexer/metadata_dictionary/base.py:179: in translate return self._translate_dict(content_dict) .tox/py3/lib/python3.7/site-packages/swh/indexer/metadata_dictionary/base.py:131: in _translate_dict v = normalization_method(v) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <swh.indexer.metadata_dictionary.npm.NpmMapping object at 0x7eff080850b8> description = None def normalize_description(self, description): r"""Try to re-decode ``description`` as UTF-16, as this is a somewhat common mistake that causes issues in the database because of null bytes in JSON. >>> NpmMapping().normalize_description("foo bar") 'foo bar' >>> NpmMapping().normalize_description( ... "\ufffd\ufffd#\x00 \x00f\x00o\x00o\x00 \x00b\x00a\x00r\x00\r\x00 \x00" ... ) 'foo bar' >>> NpmMapping().normalize_description( ... "\ufffd\ufffd\x00#\x00 \x00f\x00o\x00o\x00 \x00b\x00a\x00r\x00\r\x00 " ... ) 'foo bar' >>> NpmMapping().normalize_description( ... # invalid UTF-16 and meaningless UTF-8: ... "\ufffd\ufffd\x00#\x00\x00\x00 \x00\x00\x00\x00f\x00\x00\x00\x00" ... ) is None True """ # XXX: if this function ever need to support more cases, consider # switching to https://pypi.org/project/ftfy/ instead of adding more hacks > if description.startswith("\ufffd\ufffd") and "\x00" in description: E AttributeError: 'NoneType' object has no attribute 'startswith' .tox/py3/lib/python3.7/site-packages/swh/indexer/metadata_dictionary/npm.py:158: AttributeError