{"record":{"id":"8e1cf1100ce8578a","repo":"quarkusio/quarkus","slug":"json-array-ended-without-8e1cf1","errorCode":null,"errorMessage":"Json array ended without ]","messagePattern":"Json array ended without \\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/json/src/main/java/io/quarkus/bootstrap/json/JsonReader.java","lineNumber":156,"sourceCode":"\n        final List<JsonValue> elements = new ArrayList<>();\n\n        while (position < length) {\n            ignoreWhitespace();\n            switch (peekChar()) {\n                case ']':\n                    position++;\n                    return new JsonArray(elements);\n                case ',':\n                    position++;\n                    break;\n                default:\n                    elements.add(readElement());\n                    break;\n            }\n        }\n\n        throw new IllegalArgumentException(\"Json array ended without ]\");\n    }\n\n    /**\n     * string\n     * |---- '\"' characters '\"'\n     * </p>\n     * characters\n     * |----- \"\"\n     * |----- character characters\n     * </p>\n     * character\n     * |----- '0020' . '10FFFF' - '\"' - '\\'\n     * |----- '\\' escape\n     * |----- escape\n     * |----- '\"'\n     * |----- '\\'\n     * |----- '/'\n     * |----- 'b'","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/json/src/main/java/io/quarkus/bootstrap/json/JsonReader.java#L138-L174","documentation":"readArray() consumes elements inside '[' ... ']'. If the input ends before a closing ']' is reached, the array is unterminated and the reader throws IllegalArgumentException. Like the missing '}' case, it signals an unbalanced or truncated JSON document.","triggerScenarios":"A JSON array literal without a closing ']', e.g. '[1, 2, 3' or nested arrays cut short like '[{\"a\": 1,' with the outer ']' missing.","commonSituations":"Streaming/paginated JSON cut mid-array; manual string building dropping the final bracket; serialization interrupted midway.","solutions":["Add the missing ']' to close the array at the reported parse position","Verify the producer of the JSON emits the complete array (check for truncation/limits)","Validate the document with a JSON validator before parsing"],"exampleFix":"// before\nString json = \"[1, 2, 3\";\n// after\nString json = \"[1, 2, 3]\";","handlingStrategy":"try-catch","validationCode":"long opens = jsonText.chars().filter(c -> c == '[').count();\nlong closes = jsonText.chars().filter(c -> c == ']').count();\nif (opens != closes) {\n    throw new IllegalArgumentException(\"Unbalanced brackets in JSON input\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    JsonValue v = new JsonReader(text).read();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"Json array ended without ]\")) {\n        // treat as truncated payload: retry the fetch or repair the document\n    }\n}","preventionTips":["Ensure array producers emit the full array including the closing ']'","Avoid manual string concatenation for arrays; use a serializer","Check pagination/streaming code for premature termination"],"tags":["json","parser","unbalanced-brackets"],"backgroundTag":"malformed-json-input","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}