{"record":{"id":"557676cfadb376f4","repo":"apache/hadoop","slug":"file-name-can-t-be-empty-string-557676","errorCode":null,"errorMessage":"File name can't be empty string","messagePattern":"File name can't be empty string","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobResourceUploader.java","lineNumber":872,"sourceCode":"  }\n\n  /**\n   * takes input as a path string for file and verifies if it exist. It defaults\n   * for file:/// if the files specified do not have a scheme. it returns the\n   * paths uri converted defaulting to file:///. So an input of /home/user/file1\n   * would return file:///home/user/file1\n   * \n   * @param file\n   * @param conf\n   * @return\n   */\n  private String validateFilePath(String file, Configuration conf)\n      throws IOException {\n    if (file == null) {\n      return null;\n    }\n    if (file.isEmpty()) {\n      throw new IllegalArgumentException(\"File name can't be empty string\");\n    }\n    String finalPath;\n    URI pathURI;\n    try {\n      pathURI = new URI(file);\n    } catch (URISyntaxException e) {\n      throw new IllegalArgumentException(e);\n    }\n    Path path = new Path(pathURI);\n    if (pathURI.getScheme() == null) {\n      FileSystem localFs = FileSystem.getLocal(conf);\n      // default to the local file system\n      // check if the file exists or not first\n      localFs.getFileStatus(path);\n      finalPath =\n          path.makeQualified(localFs.getUri(), localFs.getWorkingDirectory())\n              .toString();\n    } else {","sourceCodeStart":854,"sourceCodeEnd":890,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobResourceUploader.java#L854-L890","documentation":"JobResourceUploader.copyLog4jPropertyFile reads mapreduce.job.log4j-properties-file (MRJobConfig.MAPREDUCE_JOB_LOG4J_PROPERTIES_FILE) via validateFilePath. A null value means 'not set' and returns null, but an explicitly empty string throws IllegalArgumentException(\"File name can't be empty string\") — the property was set to '' rather than left unset.","triggerScenarios":"Passing -D mapreduce.job.log4j-properties-file= (empty value) on the command line; workflow tools that always write the key even when the user left it blank (conf.set(key, varOrDefault) with an empty default); templated XML where the placeholder resolves to empty.","commonSituations":"Oozie/Workflow <configuration> sections generated from optional parameters; shell scripts doing conf.set when a variable is defined-but-empty; migration of old mapred.system.log.properties? setups that defaulted to ''.","solutions":["Remove the property entirely instead of setting it to empty: drop the -D flag or the <property> element","In code, only set the key when the value is non-empty: if (path != null && !path.isEmpty()) conf.set(key, path)","Guard templates with defaults: ${log4jprops:file:///etc/log4j.properties} style fallback to a real path","Unset defensively before submit: conf.unset(\"mapreduce.job.log4j-properties-file\") when blank"],"exampleFix":"// before\nString props = getArgOrDefault(\"log4jprops\", \"\"); // defined but empty\nconf.set(MRJobConfig.MAPREDUCE_JOB_LOG4J_PROPERTIES_FILE, props); // -> 'File name can't be empty string'\n\n// after\nString props = getArg(\"log4jprops\");\nif (props != null && !props.isEmpty()) {\n  conf.set(MRJobConfig.MAPREDUCE_JOB_LOG4J_PROPERTIES_FILE, props);\n}","handlingStrategy":"validation","validationCode":"// only set the property when it carries a real value\nString props = getOptional(\"log4jprops\");\nif (props == null || props.isEmpty()) {\n  conf.unset(MRJobConfig.MAPREDUCE_JOB_LOG4J_PROPERTIES_FILE);\n} else {\n  conf.set(MRJobConfig.MAPREDUCE_JOB_LOG4J_PROPERTIES_FILE, props);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never write -D key= with an empty value; omit the flag instead","In generated workflows, emit the <property> element only when the value is non-empty","Unset the key defensively when it comes from user input"],"tags":["configuration","log4j","empty-value","job-submission","mapreduce"],"backgroundTag":"empty-config-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}