Skip to content

Reject out-of-range JSON integer values - #746

Merged
liuzicheng1987 merged 1 commit into
munich-data-engineering:mainfrom
sean0407:codex/reflect-cpp-682-reject-integer-overflow
Oct 18, 2026
Merged

liuzicheng1987 merged 1 commit into
munich-data-engineering:mainfrom
sean0407:codex/reflect-cpp-682-reject-integer-overflow

Conversation

@sean0407

Copy link
Copy Markdown
Contributor

Summary

Reader::to_basic_type now checks JSON integer values against the target type's bounds before casting. The focused regression covers the reported uint16_t overflow, signed upper/lower overflow, and valid narrow integer boundaries.

Fixes #682.

Evidence

  • Before: uint16_t port parsed from {"port":100200} was accepted as 34664.
  • After: The same input returns a field-specific out-of-range error. int16_t values outside both bounds are rejected; INT16_MIN and UINT16_MAX still round-trip.
  • Checks: Focused tests/json/test_integers.cpp compiled with C++20 and -Wall -Werror and ran in an isolated network-disabled container (2 tests passed); git diff --check; patch policy accepted 2 text files with no binary changes.

Merge Danger

Door: Two-way

Blast Radius: Parsing

Only JSON integer conversion to narrower integral types changes; values outside the destination type's representable range now return an error.

@liuzicheng1987

Copy link
Copy Markdown
Collaborator

@sean0407 thanks for the contribution. I am merging.

@liuzicheng1987
liuzicheng1987 merged commit bb195e2 into munich-data-engineering:main Oct 18, 2026
176 checks passed
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.

Reading should fail if integer values are out of range

2 participants