Summary
Severity: High
File: sdk/basyx/aas/model/base.py:2209-2212
Description
When using integer indexing to replace an item in OrderedNamespaceSet, the new item is added before the old item is removed. This triggers a spurious uniqueness constraint violation when the replacement shares the same id_short.
if isinstance(s, int):
deleted_items = [self._order[s]]
super().add(o) # validates uniqueness — but old item still present
self._order[s] = o
super().add(o) calls _validate_namespace_constraints(), which checks that no existing item in the set has the same attribute values as o. When replacing an item with another that has the same id_short (a common use-case — update in-place), the old item is still in the backend at this point, so the uniqueness check raises AASConstraintViolation even though the intent is a legal replacement.
Fix
Remove deleted_items from backends first, then call super().add(o), then update _order.
Summary
Severity: High
File:
sdk/basyx/aas/model/base.py:2209-2212Description
When using integer indexing to replace an item in
OrderedNamespaceSet, the new item is added before the old item is removed. This triggers a spurious uniqueness constraint violation when the replacement shares the sameid_short.super().add(o)calls_validate_namespace_constraints(), which checks that no existing item in the set has the same attribute values aso. When replacing an item with another that has the sameid_short(a common use-case — update in-place), the old item is still in the backend at this point, so the uniqueness check raisesAASConstraintViolationeven though the intent is a legal replacement.Fix
Remove
deleted_itemsfrom backends first, then callsuper().add(o), then update_order.