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

  1. Uppercase and trim the label before passing it (e.g. 'a' -> 'A').
  2. Use only the letters A-Z in the label; convert numeric column positions yourself if you have numbers.
  3. Strip whitespace/control characters from configuration values.
  4. 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

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


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/c751c746700b3db9. Report an issue: GitHub.