tools-python icon indicating copy to clipboard operation
tools-python copied to clipboard

Converting valid JSON SPDX file to tag:value gives invalid SPDX

Open vargenau opened this issue 2 years ago • 1 comments

bug.spdx.json.txt

bug.spdx.txt

bug.spdx.jsonis valid:

pyspdxtools -i bug.spdx.json

Convert to tag:value:

pyspdxtools -i bug.spdx.json -o bug.spdx

Result is invalid:

pyspdxtools -i bug.spdx
ERROR:root:There have been issues while parsing the provided document:
Error while parsing Package: ['Error while parsing PackageSourceInfo: Token did not match specified grammar rule. Line: 24']

tools-python release 0.8.2

vargenau avatar Jan 17 '24 15:01 vargenau

Thanks for the bug report! This bug is caused by the package source info which is "NOASSERTION" in the JSON file. When translating this to tag-value the string is deserialized and also serialized as NOASSERTION. This string is handled as a special word and gets a dedicated token by the tag-value parser. As NOASSERTION is no valid value for the package source info but a string is, this incosistency appears. For fields where noassertion is not explicitly allowed but a string is we ~should probably not serialize/deserialize the string into the NoAssertion object but keep it as a string in the internal data model. Also, the tag-value parser~ (edit: is already the case) should to be less strict in this case and accept NOASSERTION as a string, I'll work on a fix for this.

meretp avatar Aug 02 '24 13:08 meretp