According to AAS spec 3.1.2 (IDTA-01001), RelationshipElement.first and .second have multiplicity 0..1. Both the JSON schema
(RelationshipElement_abstract — no required array) and the XML schema (relationshipElement group — minOccurs="0") reflect this.
RelationshipElement.__init__ was updated to match (Optional[base.Reference] = None), but three places were not:
AnnotatedRelationshipElement.__init__ in basyx/aas/model/submodel.py still declares first and second as required positional arguments, contradicting its parent class and the spec.
_construct_relationship_element and _construct_annotated_relationship_element in basyx/aas/adapter/json/json_deserialization.py currently call _get_ts(dct, 'first'/'second', dict), which is a mandatory getter, causing a KeyError when either field is absent in the JSON input.
_construct_relationship_element_internal in basyx/aas/adapter/xml/xml_deserialization.py currently calls _child_construct_mandatory(element, NS_AAS + "first"/"second", ...) which would likewise raise on absent fields.
Suggested fixes:
submodel.py: update AnnotatedRelationshipElement.__init__ to first: Optional[base.Reference] = None, second: Optional[...] = None.
json_deserialization.py: replace the mandatory _get_ts calls with an optional pattern, e.g. cls._construct_reference(_get_ts(dct, 'first', dict)) if 'first' in dct else None.
xml_deserialization.py: replace _child_construct_mandatory with _failsafe_construct(element.find(NS_AAS + "first"), cls.construct_reference, cls.failsafe).
According to AAS spec 3.1.2 (IDTA-01001),
RelationshipElement.firstand.secondhave multiplicity0..1. Both the JSON schema(
RelationshipElement_abstract— norequiredarray) and the XML schema (relationshipElementgroup —minOccurs="0") reflect this.RelationshipElement.__init__was updated to match (Optional[base.Reference] = None), but three places were not:AnnotatedRelationshipElement.__init__inbasyx/aas/model/submodel.pystill declaresfirstandsecondas required positional arguments, contradicting its parent class and the spec._construct_relationship_elementand_construct_annotated_relationship_elementinbasyx/aas/adapter/json/json_deserialization.pycurrently call_get_ts(dct, 'first'/'second', dict), which is a mandatory getter, causing aKeyErrorwhen either field is absent in the JSON input._construct_relationship_element_internalinbasyx/aas/adapter/xml/xml_deserialization.pycurrently calls_child_construct_mandatory(element, NS_AAS + "first"/"second", ...)which would likewise raise on absent fields.Suggested fixes:
submodel.py: updateAnnotatedRelationshipElement.__init__tofirst: Optional[base.Reference] = None, second: Optional[...] = None.json_deserialization.py: replace the mandatory_get_tscalls with an optional pattern, e.g.cls._construct_reference(_get_ts(dct, 'first', dict)) if 'first' in dct else None.xml_deserialization.py: replace_child_construct_mandatorywith_failsafe_construct(element.find(NS_AAS + "first"), cls.construct_reference, cls.failsafe).