Skip to content

Conversation

@bact
Copy link
Collaborator

@bact bact commented Nov 27, 2025

To fix #330

The serialized validation messages will be something like:

  "validationMessages": [
    {
      "message": "The root element must be of type Bom or software_Sbom. Found: <class 'spdx_python_model.bindings.v3_0_1.software_Package'>",
      "spdxId": "https://swinslow.net/spdx-examples/example1/hello-v3-specv3/SPDXRef-gnrtd4",
      "parentId": "https://swinslow.net/spdx-examples/example1/hello-v3-specv3/document0",
      "elementType": "None"
    }
  ],

Signed-off-by: Arthit Suriyawongkul <[email protected]>
@bact bact added this to the 4.1 milestone Nov 27, 2025
@bact bact added the bug Something isn't working label Nov 27, 2025
Copilot finished reviewing on behalf of bact November 27, 2025 13:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds JSON serialization support for validation messages to fix issue #330. The main change introduces a new get_validation_messages_json function that converts ValidationMessage objects into JSON-serializable dictionaries, including optional context details (spdx_id, parent_id, element_type) when verbose mode is enabled. The PR also refactors attribute access in base_checker.py to use defensive getattr calls with defaults.

Key changes:

  • Added get_validation_messages_json function to serialize validation messages with optional context details
  • Modified output_json method to use the new serialization function instead of simple string conversion
  • Applied defensive programming pattern with getattr throughout the output methods in base_checker.py

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
ntia_conformance_checker/report.py Added get_validation_messages_json function to serialize validation messages to JSON format with optional context details
ntia_conformance_checker/base_checker.py Updated output methods to use the new JSON serialization function and applied defensive attribute access pattern
a.json Example output file showing the new JSON structure (should be removed from PR)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

bact added 4 commits November 27, 2025 15:19
Signed-off-by: Arthit Suriyawongkul <[email protected]>
Signed-off-by: Arthit Suriyawongkul <[email protected]>
Signed-off-by: Arthit Suriyawongkul <[email protected]>
Signed-off-by: Arthit Suriyawongkul <[email protected]>
Copy link
Collaborator

@jspeed-meyers jspeed-meyers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you.

Signed-off-by: Arthit Suriyawongkul <[email protected]>
@bact bact merged commit 1e9b9bc into spdx:main Nov 28, 2025
24 checks passed
@bact bact deleted the serialize-validation-msg-json branch November 28, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Serialize ValidationMessage

2 participants