Skip to content

Comments

SPDX: Replace deprecated documentDescribes with DESCRIBES relationships#2065

Open
gyanranjanpanda wants to merge 1 commit intoaboutcode-org:mainfrom
gyanranjanpanda:fix/spdx-replace-documentDescribes
Open

SPDX: Replace deprecated documentDescribes with DESCRIBES relationships#2065
gyanranjanpanda wants to merge 1 commit intoaboutcode-org:mainfrom
gyanranjanpanda:fix/spdx-replace-documentDescribes

Conversation

@gyanranjanpanda
Copy link

While working on the SPDX output, I noticed we're still emitting the documentDescribes top-level field even though it was deprecated in the SPDX 2.3 specification in favour of explicit DESCRIBES relationships inside the relationships array (see spdx/spdx-spec#395).

This PR removes documentDescribes from serialization and emits the equivalent DESCRIBES relationships instead, prepended so that document-level entries appear before package-level ones, keeping the ordering deterministic.

Deserialization is fully backward compatible. If an older SPDX document still uses documentDescribes, Document.from_data() transparently converts it, so existing test data and externally generated SBOMs continue to load correctly.

What changed:

  • Document.as_dict() no longer emits documentDescribes; it now prepends DESCRIBES relationships derived from the internal describes list.
    • Document.from_data() reconstructs describes from the legacy field if present, or from DESCRIBES relationships where spdxElementId matches the document ID.
    • The asgiref-3.3.0.spdx.json fixture is updated accordingly.
    • Two new tests cover the happy path and the backward-compat round-trip.
      Testing:
Ran 26 tests in 0.167s 

While working on SPDX output, I noticed we're still using the
documentDescribes field even though it was deprecated in SPDX 2.3 in
favour of explicit DESCRIBES relationships in the relationships array.

This removes that field from serialization and instead writes equivalent
DESCRIBES relationships, prepended so document-level entries appear first.
Reading is still backward compatible — if an older document uses
documentDescribes, it's transparently converted when parsed.

Updated the asgiref fixture and added two new tests: one that confirms
the deprecated field no longer appears in output, and one that verifies
older documents round-trip correctly to the new format.

Signed-off-by: Gyan Ranjan Panda <gyanranjanpanda@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant