{"record":{"id":"37dd47ec679e5253","repo":"apache/hadoop","slug":"name-cannot-be-null-or-emtpy","errorCode":null,"errorMessage":"Name cannot be NULL or emtpy","messagePattern":"Name cannot be NULL or emtpy","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/lib/MultipleOutputs.java","lineNumber":192,"sourceCode":"    List<String> definedChannels = getNamedOutputsList(conf);\n    if (alreadyDefined && definedChannels.contains(namedOutput)) {\n      throw new IllegalArgumentException(\"Named output '\" + namedOutput +\n        \"' already alreadyDefined\");\n    } else if (!alreadyDefined && !definedChannels.contains(namedOutput)) {\n      throw new IllegalArgumentException(\"Named output '\" + namedOutput +\n        \"' not defined\");\n    }\n  }\n\n  /**\n   * Checks if a named output name is valid token.\n   *\n   * @param namedOutput named output Name\n   * @throws IllegalArgumentException if the output name is not valid.\n   */\n  private static void checkTokenName(String namedOutput) {\n    if (namedOutput == null || namedOutput.length() == 0) {\n      throw new IllegalArgumentException(\n        \"Name cannot be NULL or emtpy\");\n    }\n    for (char ch : namedOutput.toCharArray()) {\n      if ((ch >= 'A') && (ch <= 'Z')) {\n        continue;\n      }\n      if ((ch >= 'a') && (ch <= 'z')) {\n        continue;\n      }\n      if ((ch >= '0') && (ch <= '9')) {\n        continue;\n      }\n      throw new IllegalArgumentException(\n        \"Name cannot be have a '\" + ch + \"' char\");\n    }\n  }\n\n  /**","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/lib/MultipleOutputs.java#L174-L210","documentation":"MultipleOutputs validates every named-output token with checkTokenName(), which first rejects null or zero-length names with this IllegalArgumentException (the message contains the original typo 'emtpy'). The check runs from checkNamedOutputName — used by addNamedOutput/addMultiNamedOutput — and also for the multiName argument of getCollector(name, multiName, reporter) when the output is multi. It means the name string you passed is null or empty.","triggerScenarios":"addNamedOutput(conf, null, ...) or addNamedOutput(conf, \"\", ...) during job setup; mos.getCollector(\"seq\", \"\", reporter) where the empty string comes from a computed multiName (e.g. key.toString() returning empty, or a split-derived field that was blank).","commonSituations":"multiName values computed from data (dates, categories) that can be empty for some records; optional output names passed through configuration that default to unset; refactoring that leaves a placeholder empty string.","solutions":["Pass a non-empty, purely alphanumeric name (see also the character check in the same method)","When multiName derives from data, substitute a default token for blank values before calling getCollector (e.g. value.isEmpty() ? \"NA\" : value)","Validate/normalize output names in one helper used by both driver and task code"],"exampleFix":"// before: data-driven multiName can be empty -> IllegalArgumentException\nmos.getCollector(\"seq\", category, reporter);\n\n// after: normalize blank values before use\nString safeName = (category == null || category.isEmpty()) ? \"NA\" : category;\nmos.getCollector(\"seq\", safeName, reporter);","handlingStrategy":"validation","validationCode":"// normalize before registering or collecting\nstatic String safeToken(String s) {\n  return (s == null || s.trim().isEmpty()) ? \"NA\" : s.trim();\n}\nmos.getCollector(\"seq\", safeToken(multiName), reporter);","typeGuard":"static boolean isValidToken(String name) {\n  return name != null && !name.isEmpty();\n}","tryCatchPattern":null,"preventionTips":["Never pass data-derived names straight into getCollector — normalize null/empty first","Validate the multiName for every record category your data can produce, not just the happy path","Centralize naming rules in one helper used by both driver and task code"],"tags":["hadoop","mapreduce","multiple-outputs","validation","naming"],"backgroundTag":"empty-name-validation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}