Skip to content

Unify XML error paths across targets - #843

Merged
mristin merged 1 commit into
mainfrom
mristin/Unify-XML-error-paths-across-targets
Oct 11, 2026
Merged

mristin merged 1 commit into
mainfrom
mristin/Unify-XML-error-paths-across-targets

Conversation

@mristin

@mristin mristin commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

The targets reported different paths for the same XML de-serialization error. For example, a text instead of a number in the second item of a set was reported as collection/numbers/*[1] in Python and Java, numbers/*[1] in C#, Go and TypeScript, and
collection/numbers/*[1]/v in C++. We now report the same path, collection/numbers/*[2], in all six targets:

  • The path starts with the root element, e.g., something/someItems/*[1].
  • The indices are 1-based as in XPath, *[i + 1]. Only the rendering changes; the index segments stay 0-based, so the JSON paths are unchanged.

The readers do not prepend their own names anymore. Instead, the property loop prepends the property, a class instance nested in a property prepends its class element, and the containers prepend only the index. For example, C++ reads the nested instances through the new DeserializeNestedElement, the counterpart of Python's _read_nested_element, while Go and TypeScript wrap their readers in namingElement.

An error which belongs to the container itself is reported at the container, and not at an item which does not exist: text instead of list items is reported at something/someItems, and a missing tuple item at something/pair.

Go and TypeScript now skip the XML declaration before the root element, and the C# tests move the reader to the content first. Previously, the inputs with a declaration failed on it, and never reached the error they were meant to test.

We add the live test data for an error in a class instance nested in a list (something/someItems/*[1]) and in a property (something/structuralProperty/structuralFirst).

The targets reported different paths for the same XML de-serialization
error. For example, a text instead of a number in the second item of
a set was reported as ``collection/numbers/*[1]`` in Python and Java,
``numbers/*[1]`` in C#, Go and TypeScript, and
``collection/numbers/*[1]/v`` in C++. We now report the same path,
``collection/numbers/*[2]``, in all six targets:

* The path starts with the root element, *e.g.*,
  ``something/someItems/*[1]``.
* The indices are 1-based as in XPath, ``*[i + 1]``. Only the rendering
  changes; the index segments stay 0-based, so the JSON paths are
  unchanged.

The readers do not prepend their own names anymore. Instead, the
property loop prepends the property, a class instance nested in
a property prepends its class element, and the containers prepend only
the index. For example, C++ reads the nested instances through
the new ``DeserializeNestedElement``, the counterpart of Python's
``_read_nested_element``, while Go and TypeScript wrap their readers in
``namingElement``.

An error which belongs to the container itself is reported at the
container, and not at an item which does not exist: text instead of
list items is reported at ``something/someItems``, and a missing tuple
item at ``something/pair``.

Go and TypeScript now skip the XML declaration before the root element,
and the C# tests move the reader to the content first. Previously, the
inputs with a declaration failed on it, and never reached the error
they were meant to test.

We add the live test data for an error in a class instance nested in
a list (``something/someItems/*[1]``) and in a property
(``something/structuralProperty/structuralFirst``).
@mristin
mristin force-pushed the mristin/Unify-XML-error-paths-across-targets branch from a1360a3 to c6c94d5 Compare October 11, 2026 21:39
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 38177255675

Coverage increased (+0.002%) to 90.141%

Details

  • Coverage increased (+0.002%) from the base build.
  • Patch coverage: Could not be determined — this PR's diff is too large for GitHub to return (406 error at GitHub).
  • 70 coverage regressions across 5 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

70 previously-covered lines in 5 files lost coverage.

File Lines Losing Coverage Coverage
aas_core_codegen/csharp/lib/_generate_xmlization.py 23 96.2%
aas_core_codegen/cpp/lib/_generate_xmlization.py 19 97.35%
aas_core_codegen/golang/lib/_generate_xmlization.py 13 97.62%
aas_core_codegen/java/lib/_generate_xmlization.py 12 98.07%
aas_core_codegen/typescript/lib/_generate_xmlization.py 3 99.07%

Coverage Stats

Coverage Status
Relevant Lines: 50217
Covered Lines: 45266
Line Coverage: 90.14%
Coverage Strength: 2.7 hits per line

💛 - Coveralls

@mristin
mristin merged commit fe9c422 into main Oct 11, 2026
5 checks passed
@mristin

mristin commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

@chris-koo please mind these changes.

@mristin
mristin deleted the mristin/Unify-XML-error-paths-across-targets branch October 11, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants