basyx-python-sdk icon indicating copy to clipboard operation
basyx-python-sdk copied to clipboard

adapter.json: Non-deterministic array order in serialized JSON

Open thammel opened this issue 5 months ago • 1 comments

JSON arrays that originate from unordered Python sets are serialized in non-deterministic order. Affected are the top-level object lists and set-valued attributes such as submodel and isCaseOf.

Expected behavior: Serializing the same AAS twice produces byte-identical JSON, so output is reproducible across runs.

Actual behavior: Array element order varies between runs. Set iteration order depends on hash randomization (PYTHONHASHSEED), so each serialization can emit a different ordering. This makes output non-reproducible — complicates diffing, caching, and snapshot testing.

thammel avatar Jun 16 '26 10:06 thammel

What's your use-case?

Personally, I think it'd be a good feature to have consistent outputs. However, the specification of the AAS defines the output as unordered (we have discussed this several times already), so you cannot guarantuee order when getting AAS files elsewhere. Semantic comparision of AAS data is a complex question.

I will mark this as a discussion for the future, since I can't currently see how complex this would be to implement (nor if it would produce backward incompatible changes).

Edit: Just saw that you already provided a fix. I'll review it and let's see if there's any complicating issues.

s-heppner avatar Jun 19 '26 11:06 s-heppner