{"record":{"id":"8bce2d25cc23dc1a","repo":"apache/hadoop","slug":"error-processing-uri","errorCode":null,"errorMessage":"Error processing URI","messagePattern":"Error processing URI","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":693,"sourceCode":"    if (FileUtil.compareFs(remoteFs, jtFs)) {\n      return originalPath;\n    }\n\n    boolean root = false;\n    if (ROOT_PATH.equals(originalPath.toUri().getPath())) {\n      // \"/\" needs special treatment\n      root = true;\n    } else {\n      // If originalPath ends in a \"/\", then remove it so\n      // that originalPath.getName() does not return an empty string\n      String uriString = originalPath.toUri().toString();\n      if (uriString.endsWith(\"/\")) {\n        try {\n          URI strippedURI =\n              new URI(uriString.substring(0, uriString.length() - 1));\n          originalPath = new Path(strippedURI);\n        } catch (URISyntaxException e) {\n          throw new IllegalArgumentException(\"Error processing URI\", e);\n        }\n      }\n    }\n\n    // this might have name collisions. copy will throw an exception\n    // parse the original path to create new path\n    Path newPath = root ?\n        parentDir : new Path(parentDir, originalPath.getName());\n    FileUtil.copy(remoteFs, originalPath, jtFs, newPath, false, conf);\n    jtFs.setReplication(newPath, replication);\n    jtFs.makeQualified(newPath);\n    return newPath;\n  }\n\n  /**\n   * Checksum a local resource file and call use for that resource with the scm.\n   */\n  private URI useSharedCache(URI sourceFile, String resourceName,","sourceCodeStart":675,"sourceCodeEnd":711,"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#L675-L711","documentation":"In copyRemoteFiles, a source URI ending in '/' would make originalPath.getName() return an empty string, so the code strips the trailing slash by re-parsing the shortened string with new URI(...). If that shortened string is still syntactically invalid, the URISyntaxException is rethrown as IllegalArgumentException('Error processing URI'). Like its sibling checks, this is a defensive parse on input you supplied via -files/-libjars/-archives.","triggerScenarios":"A -files/-archives entry ending in '/' whose stem is still illegal (e.g. 'hdfs://nn/dir/#', double slashes, an entry that is only a fragment); hand-concatenated URIs like \"hdfs://\" + host + \"/dir/\" producing malformed schemes when combined with trailing slashes; paths from templating systems that leave stray characters before the final '/'.","commonSituations":"Scripts building paths by string concatenation; configuration templates with a trailing slash plus placeholder substitution that empties a component; rare — most malformed entries fail earlier at new URI(entry), so this specific message signals a slash-suffixed pathological value.","solutions":["Drop the trailing '/' from distributed-cache entries — point at the file itself, not a directory-style path","Build URIs with the API (new URI(scheme, authority, path, fragment)) or Path instead of concatenation","Sanitize entries in a pre-submit validation loop: reject values ending in '/' or failing new URI(...)","Log the exact -files/-libjars/-archives values when this fires; the message omits the original string"],"exampleFix":"# before\nhadoop jar app.jar Driver -files \"hdfs://nn/data/#\" in out\n# IllegalArgumentException: Error processing URI\n\n# after\nhadoop jar app.jar Driver -files \"hdfs://nn/data/side-data.txt\" in out","handlingStrategy":"validation","validationCode":"// reject slash-terminated or otherwise pathological cache entries\nstatic void checkEntry(String s) {\n  if (s.endsWith(\"/\")) throw new IllegalArgumentException(\"Cache entry must name a file, not end in '/': \" + s);\n  try { new URI(s); } catch (URISyntaxException e) {\n    throw new IllegalArgumentException(\"Cache entry is not a valid URI: \" + s, e);\n  }\n}","typeGuard":"static boolean isValidCacheUri(String s) {\n  if (s == null || s.endsWith(\"/\")) return false;\n  try { new URI(s); return true; }\n  catch (URISyntaxException e) { return false; }\n}","tryCatchPattern":null,"preventionTips":["Point cache entries at files, never directory-style trailing slashes","Construct URIs with new URI(scheme, authority, path, fragment) or Path, not concatenation","Validate the full -files/-libjars/-archives list pre-submit so the failing value is logged"],"tags":["uri","distributed-cache","path-normalization","job-submission","mapreduce"],"backgroundTag":"uri-parse-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}