{"record":{"id":"4f3a9b8047cb6b2d","repo":"quarkusio/quarkus","slug":"string-not-closed-4f3a9b","errorCode":null,"errorMessage":"String not closed","messagePattern":"String not closed","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/json/src/main/java/io/quarkus/bootstrap/json/JsonReader.java","lineNumber":224,"sourceCode":"                return new JsonString(value);\n            }\n\n            if ('\\\\' == ch) {\n                if (unescapedValue == null) {\n                    unescapedValue = new StringBuilder().append(text, start, position - 1);\n                }\n                final int escaped = nextChar();\n                if (escaped == 'u') {\n                    unescapedValue.append(readUnicode());\n                } else {\n                    unescapedValue.appendCodePoint(unescape(escaped));\n                }\n            } else if (unescapedValue != null) {\n                unescapedValue.appendCodePoint(ch);\n            }\n        }\n\n        throw new IllegalArgumentException(\"String not closed\");\n    }\n\n    private static int unescape(int ch) {\n        return switch (ch) {\n            case 'b' -> '\\b';\n            case 'n' -> '\\n';\n            case 't' -> '\\t';\n            case 'f' -> '\\f';\n            case 'r' -> '\\r';\n            default -> ch;\n        };\n    }\n\n    private char readUnicode() {\n        final int digit1 = Character.digit(nextChar(), 16);\n        final int digit2 = Character.digit(nextChar(), 16);\n        final int digit3 = Character.digit(nextChar(), 16);\n        final int digit4 = Character.digit(nextChar(), 16);","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/json/src/main/java/io/quarkus/bootstrap/json/JsonReader.java#L206-L242","documentation":"readString() consumes characters until a closing '\"'. If the end of input is reached while still inside a string literal, the string was never closed and the reader throws IllegalArgumentException. This catches unterminated string values in malformed JSON.","triggerScenarios":"A string value missing its final quote, e.g. '{\"name\": \"abc' — the parser consumes to EOF and throws. Also caused by an unescaped '\"' earlier in the string swallowing the intended closing quote.","commonSituations":"Hand-editing JSON and deleting a quote; unescaped inner quotes like \"He said \"hi\"\" leaving the string unterminated; truncated payloads ending mid-string.","solutions":["Add the missing closing double quote to the string value","Escape any inner double quotes as \\\" so the string terminates where intended","Validate the JSON and inspect the tail of the input to see where the string is left open"],"exampleFix":"// before\n{\"quote\":\"He said \"hi\"\"}\n// after\n{\"quote\":\"He said \\\"hi\\\"\"}","handlingStrategy":"try-catch","validationCode":"// Quick sanity check: an even number of unescaped double quotes\nint count = 0;\nfor (int i = 0; i < jsonText.length(); i++) {\n    if (jsonText.charAt(i) == '\"' && (i == 0 || jsonText.charAt(i - 1) != '\\\\')) count++;\n}\nif (count % 2 != 0) {\n    throw new IllegalArgumentException(\"Odd number of unescaped quotes — unterminated string\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    JsonValue v = new JsonReader(text).read();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"String not closed\")) {\n        // inspect the tail of the input for a missing quote or unescaped inner quote\n    }\n}","preventionTips":["Always escape inner double quotes as \\\" in string values","Count unescaped quotes as a cheap pre-parse sanity check","Validate edited JSON with a linter before parsing"],"tags":["json","parser","unterminated-string"],"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-12T22:17:10.623Z"}