quarkusio/quarkus · error · IllegalStateException
Unexpected character at <lineNumber>:<pos>, current state is
Error message
Unexpected character at <lineNumber>:<pos>, current state is <state.name()>
What it means
RedisDataLoader parses a RESP-like text script where each line is a command followed by whitespace-separated arguments. The parser encountered a character it cannot process in the current state and throws IllegalStateException with line, column and state to pinpoint the malformed token.
Source
Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/RedisDataLoader.java:111
request.arg(getAndClear(current));
state = State.ARGUMENTS;
}
} else if (state == State.PARAM_IN_QUOTES) {
if (c != '\'') {
current.append(c);
} else {
request.arg(getAndClear(current));
state = State.ARGUMENTS;
}
} else if (state == State.PARAM_IN_DOUBLE_QUOTES) {
if (c != '"') {
current.append(c);
} else {
request.arg(getAndClear(current));
state = State.ARGUMENTS;
}
} else {
throw new IllegalStateException("Unexpected character at " + lineNumber + ":" + pos
+ ", current state is " + state.name());
}
}
if (current.length() > 0) {
if (state == State.COMMAND) {
request = Request.cmd(Command.create(getAndClear(current)));
} else if (state == State.PARAM) {
request.arg(getAndClear(current));
} else {
throw new IllegalStateException("End of line unexpected at " + lineNumber + ":" + pos);
}
}
return request;
}
View on GitHub (pinned to e1c734241f)
Solutions
- Open the file at the reported line:column and fix or remove the offending character
- Keep each command on a single line: command name followed by space-separated arguments, no inline comments or stray quotes
- Escape or remove special characters (quotes, commas, brackets) from argument values
- Regenerate the import file from a known-good export or official seed script
Example fix
// before (import.redis) SET mykey "hello world" // inline comment breaks parser // after SET mykey hello-world // one command per line, plain args # comments only on their own line if supported by your file format
Defensive patterns
Strategy: validation
Validate before calling
List<String> lines = java.nio.file.Files.readAllLines(java.nio.file.Path.of(path));
for (int i = 0; i < lines.size(); i++) {
String line = lines.get(i).trim();
if (!line.isEmpty() && !line.matches("[A-Za-z]+(\s+[^\s\"',]+)*")) {
throw new IllegalStateException("Suspicious syntax at line " + (i + 1) + ": " + line);
}
} Try / catch
try {
RedisDataLoader.load(vertx, redis, path);
} catch (IllegalStateException e) {
log.error("Malformed import script: " + e.getMessage());
} Prevention
- One command per line, plain space-separated arguments, no inline comments
- Avoid quotes and special characters unless you know the loader accepts them
- Validate the script by running it against a scratch Redis before production import
When it happens
Trigger: A line in the import file contains an invalid character such as a stray quote, comma, or comment marker in the wrong position; arguments containing unquoted spaces or special characters the simple tokenizer cannot handle; edited/corrupted export file.
Common situations: Hand-editing import scripts and introducing syntax errors; pasting RESP output with binary prefixes (*) into the text loader; shell escaping issues leaving quotes in the file; comments (# or //) placed mid-line where they are not supported.
Related errors
- End of line unexpected at " + lineNumber + ":" + pos
- Unexpected end of input: ${str}
- Unexpected character '${str.charAt(pos)}' at position ${pos}
- unbalanced quotes in
- invalid config ${comment}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/8ff3ee9db184ab35.
Report an issue: GitHub.