spdx / tools-python

A Python library to parse, validate and create SPDX documents.
http://spdx.org
Apache License 2.0
189 stars 134 forks source link

Valid SPDX cannot be converted from JSON to tag:value #774

Closed vargenau closed 7 months ago

vargenau commented 11 months ago

bug.spdx.json

File bug.spdx.jsonis valid SPDX:

pyspdxtools -i bug.spdx.json

But it cannot be converted to tag:value:

pyspdxtools -i bug.spdx.json -o bug.spdx
Traceback (most recent call last):
  File "/opt/homebrew/bin/pyspdxtools", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/spdx_tools/spdx/clitools/pyspdxtools.py", line 96, in main
    write_file(document, outfile, validate=False)
  File "/opt/homebrew/lib/python3.11/site-packages/spdx_tools/spdx/writer/write_anything.py", line 22, in write_file
    tagvalue_writer.write_document_to_file(document, file_name, validate)
  File "/opt/homebrew/lib/python3.11/site-packages/spdx_tools/spdx/writer/tagvalue/tagvalue_writer.py", line 39, in write_document_to_file
    write_document_to_stream(document, out, validate, drop_duplicates)
  File "/opt/homebrew/lib/python3.11/site-packages/spdx_tools/spdx/writer/tagvalue/tagvalue_writer.py", line 34, in write_document_to_stream
    write_document(document, stream)
  File "/opt/homebrew/lib/python3.11/site-packages/spdx_tools/spdx/writer/tagvalue/tagvalue_writer.py", line 43, in write_document
    relationships_to_write, contained_files_by_package_id = scan_relationships(
                                                            ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/spdx_tools/spdx/writer/tagvalue/tagvalue_writer_helper_functions.py", line 89, in scan_relationships
    and relationship.related_spdx_element_id in files_by_spdx_id.keys()
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'SpdxNoAssertion'
armintaenzertng commented 11 months ago

Thanks for reporting this bug! I opened #778 to fix this.