You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix NamespaceSet handling in Descriptor initialization and update_from() #661
Currently, the descriptor classes in server/app/model/descriptor.py handle their extensionNamespaceSet incorrectly in two places:
AssetAdministrationShellDescriptor.__init__() calls super().__init__(), which already creates self.extension as a NamespaceSet. Then it creates a second NamespaceSet and assigns it to self.extension. Both sets register themselves in namespace_element_sets, so the descriptor has an orphaned, empty NamespaceSet that is still part of its namespace.
Descriptor.update_from() copies every instance attribute of other with setattr(self, attr, getattr(other, attr)). This replaces self.extension with the NamespaceSet of other. The items in that set still have other as their parent. The loop also replaces self.namespace_element_sets with the list of other.
Today both bugs have no visible effect, because the attribute is silently rebound. But they leave the descriptor's namespace in an inconsistent state. They also stop working as soon as assignments to NamespaceSet attributes are protected, as proposed in #619 for #65:
Descriptor.update_from() raises ValueError: Object has already a parent when other has extensions. This breaks the registry endpoints that update descriptors.
The descriptors should handle NamespaceSets the same way the SDK model classes do:
Descriptor.__init__() should accept description, display_name and extension. AssetAdministrationShellDescriptor should pass them through to it instead of setting them a second time.
Descriptor.update_from() should skip namespace_element_sets and update NamespaceSet attributes with update_nss_from() instead of rebinding them, as Referable.update_from() does.
Activity