Repository navigation
Unify XML error paths across targets - #843
Merged
Merged
Conversation
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
force-pushed
the
mristin/Unify-XML-error-paths-across-targets
branch
from
October 11, 2026 21:39
a1360a3 to
c6c94d5
Compare
Coverage Report for CI Build 38177255675Coverage increased (+0.002%) to 90.141%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions70 previously-covered lines in 5 files lost coverage.
Coverage Stats
💛 - Coveralls |
Contributor
Author
|
@chris-koo please mind these changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, andcollection/numbers/*[1]/vin C++. We now report the same path,collection/numbers/*[2], in all six targets:something/someItems/*[1].*[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 innamingElement.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 atsomething/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).