Skip to content

Unify JSON error paths across targets - #845

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

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

Conversation

@mristin

@mristin mristin commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

The targets reported different paths for the same JSON de-serialization error. For example, C++ wrote .someItems where the others wrote someItems, Python wrote the keys of JSON-able objects as ['a b'] while the others wrote ["a b"], and C++ wrote them as properties, .a b. We now report the same path in all six targets:

  • The path starts with the first property without a dot, e.g., items[0].name.
  • A key is always written as a JSON string in brackets, e.g., values["a b"][1], escaped as JSON.stringify does, so that the control characters without a short escape become \u00XX.
  • A property name which is no identifier is written in brackets as well, e.g., ["$eq"], as C# and Java already did.
  • An unexpected property is reported at the object which holds it, while Python reported it at the unexpected property itself.
  • A missing, unknown or wrong model type is reported at the instance, e.g., tricky[1], and a model type which is not a string at the property, tricky[1].modelType, as the type errors of all the other properties are.

Python now refuses a modelType on a class which carries none, as the other targets do, instead of silently accepting it.

We add live test data for a model type which is not a string, and update the checked-in C++ recordings of json_types.

@coveralls

coveralls commented Oct 12, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 38188800354

Coverage increased (+0.001%) to 90.142%

Details

  • Coverage increased (+0.001%) 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).
  • 118 coverage regressions across 6 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

118 previously-covered lines in 6 files lost coverage.

File Lines Losing Coverage Coverage
aas_core_codegen/cpp/lib/_generate_jsonization.py 28 96.61%
aas_core_codegen/csharp/lib/_generate_jsonization.py 23 96.13%
aas_core_codegen/java/lib/_generate_jsonization.py 21 96.7%
aas_core_codegen/golang/lib/_generate_jsonization.py 19 96.46%
aas_core_codegen/typescript/lib/_generate_jsonization.py 15 97.0%
aas_core_codegen/python/lib/_generate_jsonization.py 12 96.93%

Coverage Stats

Coverage Status
Relevant Lines: 50225
Covered Lines: 45274
Line Coverage: 90.14%
Coverage Strength: 2.7 hits per line

💛 - Coveralls

The targets reported different paths for the same JSON de-serialization
error. For example, C++ wrote ``.someItems`` where the others wrote
``someItems``, Python wrote the keys of JSON-able objects as
``['a b']`` while the others wrote ``["a b"]``, and C++ wrote them as
properties, ``.a b``. We now report the same path in all six targets:

* The path starts with the first property without a dot, *e.g.*,
  ``items[0].name``.
* A key is always written as a JSON string in brackets, *e.g.*,
  ``values["a b"][1]``, escaped as ``JSON.stringify`` does, so that
  the control characters without a short escape become ``\u00XX``.
* A property name which is no identifier is written in brackets as
  well, *e.g.*, ``["$eq"]``, as C# and Java already did.
* An unexpected property is reported at the object which holds it,
  while Python reported it at the unexpected property itself.
* A missing, unknown or wrong model type is reported at the instance,
  *e.g.*, ``tricky[1]``, and a model type which is not a string at
  the property, ``tricky[1].modelType``, as the type errors of all
  the other properties are.

Python now refuses a ``modelType`` on a class which carries none, as
the other targets do, instead of silently accepting it.

We add live test data for a model type which is not a string, and
update the checked-in C++ recordings of ``json_types``.
@mristin
mristin force-pushed the mristin/Unify-JSON-error-paths-across-targets branch from 8726022 to e3b9366 Compare October 12, 2026 00:38
@mristin
mristin merged commit 6bd08f4 into main Oct 12, 2026
5 checks passed
@mristin
mristin deleted the mristin/Unify-JSON-error-paths-across-targets branch October 12, 2026 08:05
@mristin

mristin commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

@chris-koo please mind this change which most probably also affects your changes.

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