Skip to content

adapter.json: Entity serializes an empty specificAssetIds array, which the schema rejects #636

Closed

Description

@leogrox

Entity.specific_asset_id is a collection, so it is never None, but the serializer guards it with is not None:

https://github.com/eclipse-basyx/basyx-python-sdk/blob/develop/sdk/basyx/aas/adapter/json/json_serialization.py#L711-L712

An entity without specific asset ids therefore serializes as "specificAssetIds": [], and every array in the AAS JSON schema carries minItems: 1. Since AASd-014 forbids specific asset ids on a co-managed entity, every co-managed Entity this SDK writes is invalid JSON, the example AAS included.

Reproduction against the official schema (aas-specs-metamodel v3.1.2):

import json, jsonschema
from basyx.aas import model
from basyx.aas.adapter.json import AASToJsonEncoder

schema = json.load(open("aas.json"))
entity = model.Entity("MyEntity", model.EntityType.CO_MANAGED_ENTITY)
data = json.loads(json.dumps(entity, cls=AASToJsonEncoder))
# {'idShort': 'MyEntity', 'modelType': 'Entity', 'entityType': 'CoManagedEntity', 'specificAssetIds': []}

jsonschema.validate(data, {"$ref": "#/definitions/Entity", "definitions": schema["definitions"]})
# ValidationError: [] should be non-empty

JsonSerializationSchemaTest.test_full_example_serialization and test_aas_example_serialization both catch this as soon as the schema file is actually present, which it isn't in CI; see the companion issue on the schema path.

The neighbouring attributes in the same method, and AssetInformation at L320, already guard on the collection being non-empty; Entity is the only place that doesn't. I checked the other element types against the schema (Submodel, SubmodelElementCollection, SubmodelElementList, Property, Operation, AnnotatedRelationshipElement, AssetAdministrationShell, ConceptDescription) and they all serialize valid documents.

Happy to send the one-line fix with tests.

Activity

  1. added a commit that references this issue on Oct 6, 2026
    a90cea8
  2. zrgt commented on Oct 6, 2026

    @zrgt
    Contributor

    Fixed in #638

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions