Skip to content

OrderedNamespaceSet.__setitem__ int: new item added before old removed, causing spurious AASConstraintViolation #498

@zrgt

Description

@zrgt

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsdkSomething to do with the `sdk` package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions