Repository navigation
Check safe integers and make JSON values public - #876
Merged
Merged
Conversation
We make the de/serialization of JSON-able values public in all SDKs so
that the aas-client3.2 implementations can use them, e.g.,
``json_value_from_jsonable`` in Python, ``JsonValueFromJsonable`` in Go,
``Deserialize.JsonValueFrom`` in C# and ``JsonValueFrom`` in C++.
A JSON number is read as a 64-bit float by the other SDKs, so we refuse
every integer outside the safe integer range [-2^53 + 1, 2^53 - 1]
consistently: for integer properties and in JSON-able values, in JSON
and XML de/serialization, in XML-RPC, in parsing with ``int`` and in
the verification. Once the verification passes, the serialization thus
works.
The bounds live in a single shared predicate per SDK, e.g., in Go:
func IsSafeInteger(value int64) bool {
return -9007199254740991 <= value && value <= 9007199254740991
}
(``common.is_safe_integer`` in Python, ``common::IsSafeInteger`` in C++,
``Common.IsSafeInteger`` in C#, ``Verification.isSafeInteger`` in Java
and ``Number.isSafeInteger`` in TypeScript), generated if
``intermediate_uses.safe_integer_checks`` holds.
We accept a whole float such as ``5.0`` for an integer property.
The new live-test data and the generated unit tests cover the bounds in
all SDKs. The generated tests set an unsafe integer at every integer
property, and check that the verification and both serializations
refuse it. We hence made ``no_seven_from`` in ``int_length_interplay``
check ``start`` against the bounds before it indexes, as an invariant
would otherwise crash on ``count = -(2 ** 53)``.
The transpiled ``int(...)`` keeps checking the safe integer range, and
we document why: TypeScript represents the integers as ``number``, so
all SDKs check the same range to behave the same.
Coverage Report for CI Build 41355765637Coverage increased (+0.1%) to 90.349%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions451 previously-covered lines in 21 files lost coverage.
Coverage Stats
💛 - Coveralls |
mristin
deleted the
mristin/Publish-JSON-values-and-check-safe-integers
branch
November 1, 2026 22:23
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.
We make the de/serialization of JSON-able values public in all SDKs so that the aas-client3.2 implementations can use them, e.g.,
json_value_from_jsonablein Python,JsonValueFromJsonablein Go,Deserialize.JsonValueFromin C# andJsonValueFromin C++.A JSON number is read as a 64-bit float by the other SDKs, so we refuse every integer outside the safe integer range [-2^53 + 1, 2^53 - 1] consistently: for integer properties and in JSON-able values, in JSON and XML de/serialization, in XML-RPC, in parsing with
intand in the verification. Once the verification passes, the serialization thus works.The bounds live in a single shared predicate per SDK, e.g., in Go:
(
common.is_safe_integerin Python,common::IsSafeIntegerin C++,Common.IsSafeIntegerin C#,Verification.isSafeIntegerin Java andNumber.isSafeIntegerin TypeScript), generated ifintermediate_uses.safe_integer_checksholds.We accept a whole float such as
5.0for an integer property.The new live-test data and the generated unit tests cover the bounds in all SDKs. The generated tests set an unsafe integer at every integer property, and check that the verification and both serializations refuse it. We hence made
no_seven_frominint_length_interplaycheckstartagainst the bounds before it indexes, as an invariant would otherwise crash oncount = -(2 ** 53).The transpiled
int(...)keeps checking the safe integer range, and we document why: TypeScript represents the integers asnumber, so all SDKs check the same range to behave the same.