Skip to content

adapter.json: Omit specificAssetIds on an Entity without any - #638

Open
LGUIUX wants to merge 1 commit into
eclipse-basyx:developfrom
LGUIUX:fix/entity-empty-specific-asset-ids
Open

LGUIUX wants to merge 1 commit into
eclipse-basyx:developfrom
LGUIUX:fix/entity-empty-specific-asset-ids

Conversation

@LGUIUX

@LGUIUX LGUIUX commented Sep 20, 2026

Copy link
Copy Markdown

Fixes #636.

Entity.specific_asset_id is a collection, so it is never None and the is not None guard let an empty one through as "specificAssetIds": []. Every array in the AAS JSON schema carries minItems: 1, and AASd-014 forbids specific asset ids on a co-managed entity, so every serialized co-managed Entity was invalid, the example AAS included.

The guard now tests the collection for content, as the neighbouring attributes and AssetInformation (L320) already do.

Testing

Two tests in test/adapter/json/test_json_serialization.py: the key is left out when the collection is empty, and still written when it isn't. Both are schema-independent, so they run whether or not the schema files are present.

python -m unittest in sdk/: 282 tests, OK. mypy and pycodestyle clean. Without the change, three fail: the new assertion plus JsonSerializationSchemaTest.test_full_example_serialization and test_aas_example_serialization, which catch it as soon as the schema file is actually there, which in CI it isn't; see #637.

`specific_asset_id` is a collection, so it is never `None` and the guard let an
empty one through as `"specificAssetIds": []`. Every array in the AAS JSON
schema carries `minItems: 1`, so that array is invalid, and AASd-014 forbids
specific asset ids on a co-managed entity, which makes every serialized
co-managed `Entity` invalid, the example AAS included.

Guard on the collection being non-empty, as the neighbouring attributes and
`AssetInformation` already do.

Signed-off-by: LGUIUX <phdl@outlook.es>
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