diff --git a/basyx/aas/model/base.py b/basyx/aas/model/base.py index bacd8b005..0a8b1d539 100644 --- a/basyx/aas/model/base.py +++ b/basyx/aas/model/base.py @@ -1012,13 +1012,14 @@ def resolve(self, provider_: "provider.AbstractObjectProvider") -> _RT: # the `is_submodel_element_list` branch, but mypy doesn't infer types based on isinstance checks # stored in boolean variables. item = item.value[int(key.value)] # type: ignore + resolved_keys[-1] += f"[{key.value}]" else: item = item.get_referable(key.value) + resolved_keys.append(item.id_short) except (KeyError, IndexError) as e: raise KeyError("Could not resolve {} {} at {}".format( "index" if is_submodel_element_list else "id_short", key.value, " / ".join(resolved_keys)))\ from e - resolved_keys.append(item.id_short) # Check type if not isinstance(item, self.type): diff --git a/test/model/test_base.py b/test/model/test_base.py index cde414573..7e186db09 100644 --- a/test/model/test_base.py +++ b/test/model/test_base.py @@ -832,7 +832,7 @@ def get_identifiable(self, identifier: Identifier) -> Identifiable: model.Property) with self.assertRaises(TypeError) as cm_3: ref4.resolve(DummyObjectProvider()) - self.assertEqual("Object retrieved at urn:x-test:submodel / list / collection / prop is not a Namespace", + self.assertEqual("Object retrieved at urn:x-test:submodel / list[0] / prop is not a Namespace", str(cm_3.exception)) with self.assertRaises(AttributeError) as cm_4: @@ -863,7 +863,7 @@ def get_identifiable(self, identifier: Identifier) -> Identifiable: with self.assertRaises(KeyError) as cm_8: ref8.resolve(DummyObjectProvider()) - self.assertEqual("'Could not resolve id_short prop_false at urn:x-test:submodel / list / collection'", + self.assertEqual("'Could not resolve id_short prop_false at urn:x-test:submodel / list[0]'", str(cm_8.exception)) with self.assertRaises(ValueError) as cm_9: