adapter.json: `Entity` serializes an empty `specificAssetIds` array, which the schema rejects
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Start in sdk/basyx/aas/adapter/json/json_serialization.py around lines 711-712 and compare Entity with the neighbouring collection guards and AssetInformation at line 320. Run JsonSerializationSchemaTest.test_full_example_serialization and test_aas_example_serialization with the AAS schema available; done means co-managed entities without specific asset IDs pass schema validation without an empty array.
Written by the indexing model from the issue text.
Description
Entity.specific_asset_id is a collection, so it is never None, but the serializer guards it with is not None:
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.
- Dominant language
- Python
- Stars
- 102
- Forks
- 52
- Avg merge
- 20d 17h
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from eclipse-basyx/basyx-python-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
bug server
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
eclipse-basyx/basyx-python-sdk#626 · 1 comment · 1 reaction ·
All issues in eclipse-basyx/basyx-python-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100