{"record":{"id":"6bec2747fb81ca06","repo":"quarkusio/quarkus","slug":"end-of-line-unexpected-at-linenumber-p","errorCode":null,"errorMessage":"End of line unexpected at \" + lineNumber + \":\" + pos","messagePattern":"End of line unexpected at \" \\+ lineNumber \\+ \":\" \\+ pos","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/RedisDataLoader.java","lineNumber":122,"sourceCode":"                if (c != '\"') {\n                    current.append(c);\n                } else {\n                    request.arg(getAndClear(current));\n                    state = State.ARGUMENTS;\n                }\n            } else {\n                throw new IllegalStateException(\"Unexpected character at \" + lineNumber + \":\" + pos\n                        + \", current state is \" + state.name());\n            }\n        }\n\n        if (current.length() > 0) {\n            if (state == State.COMMAND) {\n                request = Request.cmd(Command.create(getAndClear(current)));\n            } else if (state == State.PARAM) {\n                request.arg(getAndClear(current));\n            } else {\n                throw new IllegalStateException(\"End of line unexpected at \" + lineNumber + \":\" + pos);\n            }\n        }\n\n        return request;\n\n    }\n\n    private static String getAndClear(StringBuffer buffer) {\n        var content = buffer.toString();\n        buffer.setLength(0);\n        return content;\n    }\n\n}\n","sourceCodeStart":104,"sourceCodeEnd":137,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/RedisDataLoader.java#L104-L137","documentation":"After consuming a full line, the parser checks leftover buffered text. If a non-empty buffer remains while the state is neither COMMAND nor PARAM (e.g. mid-quote or inside an unexpected state), the line ended in an incomplete construct and the loader throws IllegalStateException with the line and position.","triggerScenarios":"An import file line ends with an unterminated quoted argument (opening quote never closed); a line ends immediately after an opening marker/token leaving the parser in a state where trailing text is invalid; truncated file (last line cut off mid-token).","commonSituations":"Truncated upload or partial copy/paste of the import script; unterminated quote due to shell escaping; file edited with an editor that stripped the final newline or characters.","solutions":["Inspect the reported line for an unterminated quote or truncated token and complete it","Ensure the file was transferred/copied fully (compare size/checksum with the source)","Add a trailing newline at end of file if the last line was cut mid-token","Rewrite the offending line as a complete single-line command"],"exampleFix":"// before (import.redis)\nSET greeting \"hello // unterminated quote\n// after\nSET greeting hello // complete, well-formed line","handlingStrategy":"validation","validationCode":"List<String> lines = java.nio.file.Files.readAllLines(java.nio.file.Path.of(path));\nfor (int i = 0; i < lines.size(); i++) {\n    String line = lines.get(i);\n    long quotes = line.chars().filter(c -> c == '\"').count();\n    if (quotes % 2 != 0) {\n        throw new IllegalStateException(\"Unbalanced quotes at line \" + (i + 1) + \": \" + line);\n    }\n}\nif (!Files.readString(Path.of(path)).endsWith(\"\\n\")) {\n    throw new IllegalStateException(\"Import file should end with a newline\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    RedisDataLoader.load(vertx, redis, path);\n} catch (IllegalStateException e) {\n    log.error(\"Incomplete line in import script: \" + e.getMessage());\n}","preventionTips":["Always terminate quoted arguments on the same line","Ensure files are fully transferred (check sizes/checksums after copy)","End the file with a trailing newline and verify the last line is complete"],"tags":["redis","parsing","data-import","syntax"],"backgroundTag":"malformed-import-script","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"}