apache/flink · error · IllegalArgumentException
Could not split string. Quoting was not closed properly.
Error message
Could not split string. Quoting was not closed properly.
What it means
Thrown by StructuredOptionsSplitter.consumeInQuotes when the end of the string is reached without finding a closing quote character. The method scans from the opening quote to the matching close; hitting end-of-string means the quote was never terminated.
Source
Thrown at flink-core/src/main/java/org/apache/flink/configuration/StructuredOptionsSplitter.java:163
}
private static int consumeInQuotes(
String string, char quote, int cursor, StringBuilder builder) {
for (int i = cursor + 1; i < string.length(); i++) {
char c = string.charAt(i);
if (c == quote) {
if (i + 1 < string.length() && string.charAt(i + 1) == quote) {
builder.append(c);
i += 1;
} else {
return i + 1;
}
} else {
builder.append(c);
}
}
throw new IllegalArgumentException(
"Could not split string. Quoting was not closed properly.");
}
private static int consumeUnquoted(
String string, char delimiter, int cursor, StringBuilder builder) {
int i;
for (i = cursor; i < string.length(); i++) {
char c = string.charAt(i);
if (c == delimiter) {
return i;
}
builder.append(c);
}
return i;
}
View on GitHub (pinned to 2f3c205e92)
Solutions
- Add the matching closing quote (single or double) to complete the quoted segment.
- If the value shouldn't be quoted, remove the opening quote.
- Escape internal single quotes by doubling ('') when using single-quote wrapping.
Example fix
# before my.value: 'unclosed # after my.value: 'closed'
Defensive patterns
Strategy: validation
Validate before calling
long single = rawValue.chars().filter(c -> c == '\'').count();
long dbl = rawValue.chars().filter(c -> c == '"').count();
if (single % 2 != 0 || dbl % 2 != 0) {
throw new IllegalArgumentException("Unclosed quote in value");
} Try / catch
try {
StructuredOptionsSplitter.splitEscaped(value, delimiter);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("not closed properly")) { /* add closing quote */ }
} Prevention
- Always close opened quotes.
- Use a YAML linter that checks quote balance.
- Prefer YAML native structures over hand-rolled delimited strings.
When it happens
Trigger: Config values with an unclosed quote: my.map: 'key:value (missing closing quote). Also when an escaped quote ('') is intended but only one quote is present, or the closing quote was accidentally deleted.
Common situations: Editing YAML config and forgetting to close a quoted string. Shell quoting that strips the closing quote. Values that begin with a quote due to template substitution errors.
Related errors
- Could not split string. Illegal quoting at position: {}
- No cluster id was specified. Please specify a cluster to whi
- The configuration directory '{}', specified in the '{}' envi
- The configuration directory was not specified. Please specif
- No valid command-line found.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/fb0de1d1ea6a1295.
Report an issue: GitHub.