Skip to content

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

Merged
zrgt merged 1 commit into
eclipse-basyx:developfrom
leogrox:fix/entity-empty-specific-asset-ids
Oct 6, 2026
Merged

zrgt merged 1 commit into
eclipse-basyx:developfrom
leogrox:fix/entity-empty-specific-asset-ids

Conversation

@leogrox

@leogrox leogrox 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.

Comment on lines +711 to +712
# specific_asset_id is a collection, so it is never None. An empty one has to be
# left out: the schema gives specificAssetIds minItems 1, as it does every array.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove the comments. Commit message would be enough.

@s-heppner s-heppner modified the milestones: Release 2.2.0, Release 2.3.0 Oct 2, 2026
@s-heppner

Copy link
Copy Markdown
Member

I bumped the milestone for this to version 2.3.0, as we release 2.2.0 today and this is not ready yet.

@leogrox
leogrox force-pushed the fix/entity-empty-specific-asset-ids branch 3 times, most recently from ad925bb to 188047b Compare October 5, 2026 14:06
`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>
@leogrox
leogrox force-pushed the fix/entity-empty-specific-asset-ids branch from 188047b to 1dc8a24 Compare October 5, 2026 14:09
@leogrox

leogrox commented Oct 5, 2026

Copy link
Copy Markdown
Author

Done: the comment is gone and the reasoning is in the commit message. I kept the short comments in the two tests, since they say which AASd-014 case each one covers; happy to drop those too if you'd rather.

@zrgt
zrgt merged commit a90cea8 into eclipse-basyx:develop Oct 6, 2026
18 checks passed
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.

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

3 participants