{"record":{"id":"14af2c2e2c06c6ab","repo":"quarkusio/quarkus","slug":"json-array-ended-without","errorCode":null,"errorMessage":"Json array ended without ]","messagePattern":"Json array ended without \\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/builder/src/main/java/io/quarkus/builder/JsonReader.java","lineNumber":168,"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":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/builder/src/main/java/io/quarkus/builder/JsonReader.java#L150-L186","documentation":"JsonReader.readArray() parses a JSON array character by character and loops consuming elements until it sees ']'. If the input text is exhausted (position reaches end of text) before the closing bracket is found, the loop exits and the parser throws this IllegalArgumentException. It means the JSON array being read was truncated or malformed — e.g. it had a '[' but no matching ']'.","triggerScenarios":"Passing a JSON string/document to the Quarkus build-step JSON reader where an array starts with '[' but the input ends (or a syntax error swallows the closing bracket) before ']' is encountered, e.g. \"[1,2,3\" or an element that consumed too many characters.","commonSituations":"Hand-written or templated JSON in build configuration that was cut off; build-step arguments serialized from a file that was truncated; copy-paste errors dropping the final ']' in JSON payloads passed to the builder; unescaped characters inside strings that hid the real ']' delimiter.","solutions":["Validate the JSON with a standard parser (e.g. jakarta.json or Jackson) before feeding it to JsonReader to pinpoint the truncation.","Inspect the input around the end of each array and add the missing ']' delimiter.","Check that string values inside the array are properly quoted and escaped so a stray '\"' is not swallowing the rest of the array.","If the JSON comes from a file or template, verify it was written/completed fully (file size, no truncation by the generator)."],"exampleFix":"// before\nString json = \"[{\\\"name\\\":\\\"a\\\"}\"; // missing ]\nJsonReader.parse(json);\n\n// after\nString json = \"[{\\\"name\\\":\\\"a\\\"}]\";\nJsonReader.parse(json);","handlingStrategy":"validation","validationCode":"boolean isBalanced(String json) {\n    int depth = 0;\n    boolean inStr = false;\n    for (int i = 0; i < json.length(); i++) {\n        char c = json.charAt(i);\n        if (c == '\"' && (i == 0 || json.charAt(i - 1) != '\\\\')) inStr = !inStr;\n        if (!inStr && c == '[') depth++;\n        if (!inStr && c == ']') depth--;\n    }\n    return depth == 0 && !inStr;\n}\n// call before parsing: if (!isBalanced(input)) throw new IllegalArgumentException(\"unbalanced JSON\");","typeGuard":null,"tryCatchPattern":"try {\n    JsonReader.parse(json);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"ended without ]\")) {\n        throw new ConfigException(\"Truncated JSON array in input; check for a missing ]\", e);\n    }\n    throw e;\n}","preventionTips":["Validate JSON with a standard parser before feeding custom readers","Generate JSON via a serializer instead of string concatenation","Verify generated files are fully written before consuming them"],"tags":["json","parser","syntax-error"],"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"}