apache/hadoop · error · IllegalArgumentException
Name cannot be have a '{}' char
Error message
Name cannot be have a '{}' char What it means
checkTokenName() in MultipleOutputs accepts only the characters A-Z, a-z and 0-9 in a named output (and in a multi name); every other character triggers this IllegalArgumentException (the message grammar is original: "Name cannot be have a ..."). Notably underscore, dash and dot are NOT allowed in this mapred-era validator. The check runs for addNamedOutput/addMultiNamedOutput and for the multiName of getCollector on multi outputs.
Source
Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/lib/MultipleOutputs.java:205
* @param namedOutput named output Name
* @throws IllegalArgumentException if the output name is not valid.
*/
private static void checkTokenName(String namedOutput) {
if (namedOutput == null || namedOutput.length() == 0) {
throw new IllegalArgumentException(
"Name cannot be NULL or emtpy");
}
for (char ch : namedOutput.toCharArray()) {
if ((ch >= 'A') && (ch <= 'Z')) {
continue;
}
if ((ch >= 'a') && (ch <= 'z')) {
continue;
}
if ((ch >= '0') && (ch <= '9')) {
continue;
}
throw new IllegalArgumentException(
"Name cannot be have a '" + ch + "' char");
}
}
/**
* Checks if a named output name is valid.
*
* @param namedOutput named output Name
* @throws IllegalArgumentException if the output name is not valid.
*/
private static void checkNamedOutputName(String namedOutput) {
checkTokenName(namedOutput);
// name cannot be the name used for the default output
if (namedOutput.equals("part")) {
throw new IllegalArgumentException(
"Named output name cannot be 'part'");
}
}View on GitHub (pinned to 2add963021)
Solutions
- Restrict names to letters and digits only: camelCase or simple concatenation ('clickstream', '202401')
- Sanitize computed names before use: name.replaceAll("[^A-Za-z0-9]", "")
- Centralize naming in one helper used by both driver and task so both sides apply the same sanitization
Example fix
// before: '-' is rejected by checkTokenName MultipleOutputs.addNamedOutput(conf, "click-stream", TextOutputFormat.class, Text.class, Text.class); // after: alphanumeric-only name MultipleOutputs.addNamedOutput(conf, "clickstream", TextOutputFormat.class, Text.class, Text.class);
Defensive patterns
Strategy: validation
Validate before calling
static String sanitizeToken(String s) {
String t = (s == null) ? "" : s.replaceAll("[^A-Za-z0-9]", "");
return t.isEmpty() ? "NA" : t;
}
// use everywhere a named output / multi name is built
MultipleOutputs.addNamedOutput(conf, sanitizeToken(channel), fmt, k, v); Type guard
static boolean isAlphanumericToken(String name) {
return name != null && name.matches("[A-Za-z0-9]+");
} Prevention
- Remember the old-API validator allows ONLY [A-Za-z0-9] — no '_', '-', '.' or '/'
- Run generated names through a single sanitizer before addNamedOutput/getCollector
- Add a unit test that registers and collects with your real production name set
When it happens
Trigger: addNamedOutput(conf, "click-stream", ...), "out_1", "cat.ext" or any name containing '-', '_', '.', '/' or whitespace. Also mos.getCollector("seq", "2024-01", reporter) — the dash in the date fails the check even though the named output itself was registered fine.
Common situations: Natural naming from file names, dates or categories ('click_stream', '2024-01') that includes separators; ports of the new-API org.apache.hadoop.mapreduce.lib.output.MultipleOutputs code where names with '_' and '-' were tolerated, then hitting the stricter old-API validator.
Related errors
- Name cannot be NULL or emtpy
- Name cannot be have a '{ch}' char
- Named output name cannot be 'part'
- Name cannot be NULL or emtpy
- output name cannot be 'part'
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/31bea43e7d71cde0.
Report an issue: GitHub.