Skip to content

[BUG] unexpected NoPropertiesProvidedException when deserializing empty OrganizationalContact #771

Closed

Description

@Churro

Similar to #764 I found that parsing an empty contact object throws a NoPropertiesProvidedException exception

Traceback (most recent call last):
  File "/app/main.py", line 10, in main
    bom = Bom.from_json(data=bom_data)
  File "/usr/local/lib/python3.13/site-packages/serializable/__init__.py", line 375, in from_json
    _data[k] = prop_info.concrete_type.from_json(data=v)
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/serializable/__init__.py", line 375, in from_json
    _data[k] = prop_info.concrete_type.from_json(data=v)
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/serializable/__init__.py", line 375, in from_json
    _data[k] = prop_info.concrete_type.from_json(data=v)
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/serializable/__init__.py", line 366, in from_json
    items.append(prop_info.concrete_type.from_json(data=j))
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/serializable/__init__.py", line 391, in from_json
    return cls(**_data)
  File "/usr/local/lib/python3.13/site-packages/cyclonedx/model/contact.py", line 206, in __init__
    raise NoPropertiesProvidedException(
        'One of name, email or phone must be supplied for an OrganizationalContact - none supplied.'
    )
cyclonedx.exception.model.NoPropertiesProvidedException: One of name, email or phone must be supplied for an OrganizationalContact - none supplied.

Per CDX 1.6 spec, OrganizationalContact has no required fields, also see here:

message OrganizationalContact {
  // The name of the contact
  optional string name = 1;
  // The email address of the contact.
  optional string email = 2;
  // The phone number of the contact.
  optional string phone = 3;
  // An optional identifier which can be used to reference the object elsewhere in the BOM. Uniqueness is enforced within all elements and children of the root-level bom element.
  optional string bom_ref = 4;
}

SBOM to deserialize:

{
  "bomFormat" : "CycloneDX",
  "specVersion" : "1.6",
  "version" : 1,
  "metadata" : {
    "timestamp" : "2025-01-25T19:11:26Z",
    "component" : {
      "type" : "application",
      "bom-ref" : "pkg:maven/foo/[email protected]",
      "name" : "foo-bar",
      "supplier": {
        "name": "foo",
        "contact": [
          {}
        ]
      }
    }
  },
  "components" : [ ],
  "dependencies" : [ ]
}

Parsing code:

import json
import traceback

from cyclonedx.model.bom import Bom

def main() -> None:
    try:
        with open("repr.json", "r") as f:
            bom_data = json.load(f)
            bom = Bom.from_json(data=bom_data)
            print(bom)
    except BaseException as e:
        print(traceback.format_exc())

if __name__ == "__main__":
    main()

Activity

  1. jkowalleck commented on Feb 6, 2025

    @jkowalleck
    Member

    @Churro , thank you for the report and the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions