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

Unhashable type SpdxNoAssertion

Open nathanjacobiOXOS opened this issue 1 year ago • 0 comments

Hi there, if any relationships contain a NOASSERTION relationship, represented by the object SpdxNoAssertion(), then there will be a failure to write to file

  File "path/to/lib/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'

The current work around I found is changing the if statements in scan_relationships to the following (lines 87-89)

        if (
            relationship.relationship_type == RelationshipType.CONTAINS
            and relationship.spdx_element_id in packages_spdx_ids 
            and str(relationship.related_spdx_element_id) in files_by_spdx_id.keys()
        ):

Alternatively for a user side fix, replace your SpdxNoAssertion with "NOASSERTION" in any relationship or str(SpdxNoAssertion())

Also, I just want to voice some disappointment in the complete lack of backwards compatibility in the 0.7.1->0.8.0 upgrade. I appreciate this very useful tool and the work the developers do, but when it takes as much time to fix my old script that was working as it would to just manually write and SPDX document by hand, it is very frustrating for me as a user. I hope you consider more backwards compatibility in future major patches. Thanks!

nathanjacobiOXOS avatar May 07 '24 14:05 nathanjacobiOXOS