fix: std.parseJson reports truncated input cleanly#1042
Open
He-Pin wants to merge 1 commit into
Open
Conversation
e58c801 to
b7932d1
Compare
Collaborator
|
This PR seems incorrect. a lot of files are modified. |
b7932d1 to
d244bc7
Compare
Motivation: std.parseJson on empty or truncated JSON input leaked the underlying parser's incomplete-input failure instead of returning a stable sjsonnet error. Modification: Handle ujson.IncompleteParseException in std.parseJson and add new_test_suite regressions for empty and truncated JSON input. Result: Incomplete JSON input now reports a concise Invalid JSON error.
d244bc7 to
9fc7301
Compare
Contributor
Author
|
fixed |
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.
Motivation
std.parseJsonshould report incomplete JSON input as a Jsonnet runtime error instead of leaking an internal ujson exception. Before this change, empty or truncated JSON strings produced[std.parseJson] Internal Error, which made the user-facing failure look like an interpreter bug.Modification
ujson.IncompleteParseExceptioninstd.parseJson.Invalid JSON: unexpected end of JSON inputthrough the existingError.failpath.Result
std.parseJson("")failed to parse JSON: unexpected end of JSON inputfailed to parse json: EOF while parsing a value[std.parseJson] Internal Error[std.parseJson] Invalid JSON: unexpected end of JSON inputstd.parseJson('{"a":')failed to parse JSON: unexpected end of JSON inputfailed to parse json: EOF while parsing a value at line 1 column 5[std.parseJson] Internal Error[std.parseJson] Invalid JSON: unexpected end of JSON inputThe PR only changes
ManifestModule.scalaand the two regression tests with their goldens.Risks