prestodb/presto · error · IllegalArgumentException
Illegal char '%c' in label
Error message
Illegal char '%c' in label
What it means
LarkSheetsUtil.charToIndex converts a single character of a spreadsheet column label (A-Z, like Excel) into a 0-based index; any character outside 'A'-'Z' is rejected with IllegalArgumentException("Illegal char '%c' in label"). It is used by columnLabelToColumnIndex when parsing column labels.
Source
Thrown at presto-lark-sheets/src/main/java/com/facebook/presto/lark/sheets/LarkSheetsUtil.java:153
}
return String.join("", chars);
}
private static String[] buildAlphabetTable()
{
String[] table = new String[RADIX];
for (int i = 0; i < RADIX; i++) {
table[i] = Character.toString((char) ('A' + i));
}
return table;
}
private static int charToIndex(char c)
{
if (c >= 'A' && c <= 'Z') {
return c - 'A';
}
throw new IllegalArgumentException(format("Illegal char '%c' in label", c));
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Uppercase and trim the label before passing it (e.g. 'a' -> 'A').
- Use only the letters A-Z in the label; convert numeric column positions yourself if you have numbers.
- Strip whitespace/control characters from configuration values.
- If you maintain the connector, normalize with toUpperCase(Locale.ROOT).trim() inside columnLabelToColumnIndex.
Example fix
// before
int idx = LarkSheetsUtil.columnLabelToColumnIndex("a");
// after
int idx = LarkSheetsUtil.columnLabelToColumnIndex("a".trim().toUpperCase(Locale.ROOT)); Defensive patterns
Strategy: validation
Validate before calling
public static int safeColumnLabelToIndex(String label) {
String norm = label.trim().toUpperCase(Locale.ROOT);
if (!norm.matches("[A-Z]+")) throw new IllegalArgumentException("Label must be A-Z only: " + label);
return LarkSheetsUtil.columnLabelToColumnIndex(norm);
} Try / catch
try { int i = LarkSheetsUtil.columnLabelToColumnIndex(raw); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Illegal char")) { // normalize to uppercase A-Z and retry } else { throw e; } } Prevention
- Always uppercase and trim labels from user/config input
- Accept only A-Z letters, never numeric column indexes
- Strip BOM/control characters when reading config files
- Add a unit test covering lowercase and whitespace inputs
When it happens
Trigger: Calling columnLabelToColumnIndex with a label containing lowercase letters, digits, whitespace, or any non-A-Z character (e.g. 'a1', 'AA ', 'ab').
Common situations: Config passed a lowercase column label ('a' instead of 'A'); label contains a column number instead of a letter; stray whitespace or BOM characters in config files; off-by-one pasting from other tooling that uses 1-based numeric columns.
Related errors
- Invalid decimal value '{stringValue}'
- INVALID_FUNCTION_ARGUMENT
- Invalid day-time interval:
- Invalid year-month interval:
- QualifiedObjectName should have exactly 3 parts, found %s: %
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/c751c746700b3db9.
Report an issue: GitHub.