Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong/misleading error for "extra" close token (] or }) when at root level #1394

Closed
cowtowncoder opened this issue Jan 30, 2025 · 0 comments
Closed

Comments

@cowtowncoder
Copy link
Member

cowtowncoder commented Jan 30, 2025

(note: found as part of work on FasterXML/jackson-databind#4902 to enable "fail on extra tokens" DeserializationFeature).

So: odd failures seen for tests:

[ERROR]   TestSubtypesExternalPropertyMissingProperty.testDeserializationNull:141->checkOrangeBoxNull:232 » 
  JsonParse Unexpected close marker '}': expected ']' (for root starting
   at [Source: (String)"{"type":"orange","fruit":null}}"; line: 1, column: 0])

which is due to ReaderBasedJsonParser (and others), on:

    private void _closeScope(int i) throws IOException {
        if (i == INT_RBRACKET) {
            _updateLocation();
            if (!_parsingContext.inArray()) {
                _reportMismatchedEndMarker(i, '}');
            }
            _parsingContext = _parsingContext.clearAndGetParent();
            _updateToken(JsonToken.END_ARRAY);
        }
        ...
   }

in which check is assuming there always IS a start marker -- but fails to consider case where there is no open scope. It should.

This needs to be checked against all 4 backends

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

No branches or pull requests

1 participant