Skip to content

Fix std.parseJson/parseYaml abort on number overflow - #1338

Open
rwinkelman wants to merge 2 commits into
google:masterfrom
rwinkelman:fix/parsejson-overflow-abort-1337
Open

rwinkelman wants to merge 2 commits into
google:masterfrom
rwinkelman:fix/parsejson-overflow-abort-1337

Conversation

@rwinkelman

Copy link
Copy Markdown

Summary

std.parseJson only caught json::parse_error. Overflowing numbers raise out_of_range.406, which escaped to libjsonnet's CATCH and abort()ed. Same gap for std.parseYaml after RapidYAML → json::parse.

Catch json::exception and turn it into makeError like other parse failures.

Fixes #1337

Test plan

  • ./jsonnet -e 'std.parseJson("1E999")' → RuntimeError (not abort)
  • ./jsonnet -e 'std.parseYaml("1E999")' → RuntimeError (not abort)
  • ./jsonnet -e 'std.parseJson("1e2")' → 100
  • ./jsonnet -e 'std.parseJson("{")' → RuntimeError

Catch json::exception (not only parse_error) so out_of_range.406 from
overflowing numbers becomes a RuntimeError instead of aborting via
libjsonnet's CATCH.

Fixes google#1337
@google-cla

google-cla Bot commented Sep 28, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

This branch has not been deployed

No deployments
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.

std.parseJson / std.parseYaml: number overflow (out_of_range.406) aborts the process

1 participant