Skip to content

Commit 5540c3d

Browse files
authored
adapter.aasx: Allow reading AASX with wrong relationship (#381)
There are many AASX in the wild where there is an additional `www` in the relationship definition that does not belong there: ``` http://www.admin-shell.io/aasx/relationships/aasx-origin ``` whereas it should be according to the [specification]: ``` http://admin-shell.io/aasx/relationships/aasx-origin ``` Previously, our SDK did not allow for reading these AASX files with wrong relationship URL. However, since there are so many of them, this change enables them to be read, while notifying the user with a big warning message that their AASX file is actually not standard compliant and needs to be changed (see discussion in #381). Fixes #379 Fixes #383 [specification]: (https://industrialdigitaltwin.org/wp-content/uploads/2024/06/IDTA-01005-3-0-1_SpecificationAssetAdministrationShell_Part5_AASXPackageFileFormat.pdf#Page=18)
1 parent 0ed5e7c commit 5540c3d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

sdk/basyx/aas/adapter/aasx.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,20 @@ def read_into(self, object_store: model.AbstractObjectStore,
143143
try:
144144
aasx_origin_part = core_rels[RELATIONSHIP_TYPE_AASX_ORIGIN][0]
145145
except IndexError as e:
146-
raise ValueError("Not a valid AASX file: aasx-origin Relationship is missing.") from e
146+
if core_rels.get("http://www.admin-shell.io/aasx/relationships/aasx-origin"):
147+
# Since there are many AASX files with this (wrong) relationship URls in the wild, we make an exception
148+
# and try to read it anyway. However, we notify the user that this may lead to data loss, since it is
149+
# highly likely that the other relationship URLs are also wrong in that file.
150+
# See also [#383](https://github.com/eclipse-basyx/basyx-python-sdk/issues/383) for the discussion.
151+
logger.warning("SPECIFICATION VIOLATED: The Relationship-URL in your AASX file "
152+
"('http://www.admin-shell.io/aasx/relationships/aasx-origin') "
153+
"is not valid, it should be 'http://admin-shell.io/aasx/relationships/aasx-origin'. "
154+
"We try to read the AASX file anyway, but this cannot guaranteed in the future,"
155+
"and the file may not be fully readable, so data losses may occur."
156+
"Please fix this and/or notify the source of the AASX.")
157+
aasx_origin_part = core_rels["http://www.admin-shell.io/aasx/relationships/aasx-origin"][0]
158+
else:
159+
raise ValueError("Not a valid AASX file: aasx-origin Relationship is missing.") from e
147160

148161
read_identifiables: Set[model.Identifier] = set()
149162

0 commit comments

Comments
 (0)