Repository navigation
Conversation
StringDecoder built its own ParserError, so errors such as an invalid escape, an incomplete \u escape, a broken surrogate pair or a raw control character in a string had no line, column, message suffix or json_path. The parser's parseError, which adds all of these, was never used for them. StringDecoder now throws a DecodeError that carries the message and the offset to report, and the parser turns it into a regular parse error at that offset. The offsets follow the C parser: errors in an escape sequence are reported at its backslash, surrogate errors at the start of the text after the previous escape, and raw control characters where they are. The messages keep their current wording, apart from surrogate errors, whose snippet now starts at that same offset. This lets test_parse_error_position_at_newline run on JRuby, and adds a test for errors in escape sequences. Part of ruby#1123
sferik
force-pushed
the
java-string-decoding-error-position
branch
from
November 5, 2026 20:46
d867a62 to
e86a0aa
Compare
headius
reviewed
Nov 5, 2026
headius
left a comment
Contributor
There was a problem hiding this comment.
Quick review on mobile looks good. I will approve after a more rigorous review shortly.
This branch has not been deployed
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.
On JRuby, errors raised while decoding a string had no position:
The same went for incomplete
\uescapes, broken surrogate pairs and raw control characters.StringDecoderbuilt its ownParserError, so the parser'sparseError, which adds the line, column, message suffix andjson_path, was never used for these.StringDecodernow throws aDecodeErrorwith the message and the offset to report, and the parser turns it into a regular parse error at that offset. The offsets followparser.c:pinjson_string_unescape)The messages keep their current wording, except that surrogate error snippets now start at the reported offset, as in C. Porting the wording belongs with the other error message differences in #1123.
Remaining differences, left for later: