Fix Spdx2to3Converter dropping packages with no relationships - #452
Merged
Merged
Conversation
…onships Spdx2to3Converter.convertAndStore(SpdxDocument) only discovered elements by walking documentDescribes and following Relationships. Any package, file, or snippet that existed in the source document but had no relationship to anything else and wasn't part of documentDescribes was never visited, so it was silently omitted from the converted SPDX 3 output. Add a pass after the existing conversion that scans the source model store for any SpdxPackage/SpdxFile/SpdxSnippet not already converted and converts them, adding them as root elements of the resulting SpdxDocument.
goneall
requested changes
Oct 1, 2026
goneall
left a comment
Member
There was a problem hiding this comment.
Thanks @tiegz - Agree with the issue and the solution looks correct.
I would add the concrete license classes to the list of orphan element types.
There is a use case where a collection of licenses are stored in an SPDX v2 document - these may or may not be included in the root element. Adding these would properly covert those documents.
…elements Extracted licensing info, listed licenses, and listed license exceptions that exist in a source document's model store but are not reachable from documentDescribes, a relationship, or any referenced license expression were previously dropped from the SPDX 3 output, since they were never added to the document's root elements. - Add extracted licenses to the root elements list directly, since they are already unconditionally converted from the document's extractedLicenseInfos. - Scan the source model store for listed licenses and listed license exceptions not already converted, converting and rooting any orphans found (searched without a document URI prefix since these are stored under the SPDX License List namespace).
goneall
approved these changes
Oct 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Spdx2to3Converter.convertAndStore(SpdxDocument)only discovered elements by walkingdocumentDescribesand following Relationships. Any package, file, or snippet that existed in the source document but had no relationship to anything else and wasn't part ofdocumentDescribes(i.e. an orphan) was never visited, so it was silently omitted from the converted SPDX 3 output.Add a pass after the existing conversion that scans the source model store for any
SpdxPackage/SpdxFile/SpdxSnippetnot already converted and converts them, adding them as root elements of the resultingSpdxDocument.