apache/flink · error · IllegalArgumentException
Could not split string. Illegal quoting at position: {}
Error message
Could not split string. Illegal quoting at position: {} What it means
Thrown by StructuredOptionsSplitter.processTokens when a quoted token (single or double quoted) is immediately followed by a token that is not a delimiter. This means characters appear right after a closing quote without the expected separator, which indicates malformed quoting in a structured config value.
Source
Thrown at flink-core/src/main/java/org/apache/flink/configuration/StructuredOptionsSplitter.java:100
if (escape) {
return "'" + string.replaceAll("'", "''") + "'";
}
return string;
}
private static List<String> processTokens(List<Token> tokens) {
final List<String> splits = new ArrayList<>();
for (int i = 0; i < tokens.size(); i++) {
Token token = tokens.get(i);
switch (token.getTokenType()) {
case DOUBLE_QUOTED:
case SINGLE_QUOTED:
if (i + 1 < tokens.size()
&& tokens.get(i + 1).getTokenType() != TokenType.DELIMITER) {
int illegalPosition = tokens.get(i + 1).getPosition() - 1;
throw new IllegalArgumentException(
"Could not split string. Illegal quoting at position: "
+ illegalPosition);
}
splits.add(token.getString());
break;
case UNQUOTED:
splits.add(token.getString());
break;
case DELIMITER:
if (i + 1 < tokens.size()
&& tokens.get(i + 1).getTokenType() == TokenType.DELIMITER) {
splits.add("");
}
break;
}
}
return splits;View on GitHub (pinned to 2f3c205e92)
Solutions
- Ensure quoted segments are either fully self-contained or followed by the delimiter (',' or ';' or ':').
- If a value contains both quotes and delimiters, quote the entire value and escape internal quotes by doubling them.
- Remove stray quote characters that don't open/close a complete segment.
Example fix
# before my.list: 'item1'item2;item3 # after my.list: item1;item2;item3
Defensive patterns
Strategy: validation
Validate before calling
// Quick check: after a closing quote, only a delimiter or end-of-string should follow
String v = rawValue;
for (int i = 0; i < v.length(); i++) {
char c = v.charAt(i);
if ((c == '\'' || c == '"')) {
int close = v.indexOf(c, i + 1);
if (close >= 0 && close + 1 < v.length()) {
char next = v.charAt(close + 1);
if (next != ',' && next != ';' && next != ':') {
throw new IllegalArgumentException("Illegal quoting at position " + close);
}
}
}
} Try / catch
try {
StructuredOptionsSplitter.splitEscaped(value, delimiter);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("Illegal quoting")) { /* reformat value */ }
} Prevention
- Don't mix quoted and unquoted text in a single segment.
- Quote entire values, not partial ones.
- Escape internal quotes by doubling.
When it happens
Trigger: Config values like 'a'b,c (text after closing quote) or "key":value:extra where a quote is followed by non-delimiter text. The tokenizer detected a quoted segment followed by more content on the same logical segment.
Common situations: Partially quoting a value: my.list: 'item1'item2;item3. Mixing quoted and unquoted segments in a list/map value. Stray quotes from copy-paste or shell escaping leaking into the config.
Related errors
- Could not split string. Quoting was not closed properly.
- 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/9cc7e868427beed9.
Report an issue: GitHub.