{"record":{"id":"6cb23187f1837126","repo":"apache/hadoop","slug":"error-parsing-local-resource-path-path-was-not-ab-6cb231","errorCode":null,"errorMessage":"Error parsing local resource path. Path was not able to be converted to a URI: {}","messagePattern":"Error parsing local resource path\\. Path was not able to be converted to a URI: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/YARNRunner.java","lineNumber":374,"sourceCode":"  private LocalResource createApplicationResource(FileContext fs, Path p,\n      String fileSymlink, LocalResourceType type, LocalResourceVisibility viz,\n      Boolean uploadToSharedCache) throws IOException {\n    LocalResource rsrc = recordFactory.newRecordInstance(LocalResource.class);\n    FileStatus rsrcStat = fs.getFileStatus(p);\n    // We need to be careful when converting from path to URL to add a fragment\n    // so that the symlink name when localized will be correct.\n    Path qualifiedPath =\n        fs.getDefaultFileSystem().resolvePath(rsrcStat.getPath());\n    URI uriWithFragment = null;\n    boolean useFragment = fileSymlink != null && !fileSymlink.equals(\"\");\n    try {\n      if (useFragment) {\n        uriWithFragment = new URI(qualifiedPath.toUri() + \"#\" + fileSymlink);\n      } else {\n        uriWithFragment = qualifiedPath.toUri();\n      }\n    } catch (URISyntaxException e) {\n      throw new IOException(\n          \"Error parsing local resource path.\"\n              + \" Path was not able to be converted to a URI: \" + qualifiedPath,\n          e);\n    }\n    rsrc.setResource(URL.fromURI(uriWithFragment));\n    rsrc.setSize(rsrcStat.getLen());\n    rsrc.setTimestamp(rsrcStat.getModificationTime());\n    rsrc.setType(type);\n    rsrc.setVisibility(viz);\n    rsrc.setShouldBeUploadedToSharedCache(uploadToSharedCache);\n    return rsrc;\n  }\n\n  private Map<String, LocalResource> setupLocalResources(Configuration jobConf,\n      String jobSubmitDir) throws IOException {\n    Map<String, LocalResource> localResources = new HashMap<>();\n\n    Path jobConfPath = new Path(jobSubmitDir, MRJobConfig.JOB_CONF_FILE);","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/YARNRunner.java#L356-L392","documentation":"Thrown by YARNRunner.createApplicationResource while building a LocalResource for the job: it constructs a URI of the form qualifiedPath#symlink (the fragment names the localized symlink) and java.net.URI rejects it with URISyntaxException. The IOException includes the offending qualified path. Practically this means the resource path or the symlink fragment contains characters that are illegal in a URI fragment (spaces, '#', unencoded non-ASCII).","triggerScenarios":"Submitting a job where a -libjars/-archives/-files entry has a symlink name (the part after '#') containing spaces or '#', or where the resolved resource path on the default filesystem contains characters URI cannot represent unencoded — e.g. hadoop jar 'my app.jar#my lib'.","commonSituations":"Filenames with spaces in shared dirs referenced via -libjars or the distributed cache fragments; User-generated symlink names from templating (e.g. '#${name} ' with trailing whitespace); Paths returned by resolvePath containing reserved characters after unusual FS layouts","solutions":["Rename the resource or symlink so it contains only URI-safe characters (alnum, '-', '_', '.', '~'); avoid spaces and '#' in the fragment","URL-encode the fragment when building the name programmatically (URLEncoder.encode(name, \"UTF-8\"))","Sanitize user-supplied filenames before passing them to -libjars/-archives/-files","Verify with a quick new URI(path + \"#\" + symlink) smoke test on the client"],"exampleFix":"# before\nhadoop jar app.jar -libjars \"hdfs:/share/my lib.jar#my lib.jar\" MyDriver\n\n# after\nhadoop jar app.jar -libjars \"hdfs:/share/my_lib.jar#mylib.jar\" MyDriver\n# no spaces in path or fragment; fragment is the localized symlink name","handlingStrategy":"validation","validationCode":"static String safeFragment(String symlink) {\n  String s = symlink == null ? \"\" : symlink.trim();\n  if (!s.matches(\"[A-Za-z0-9._~-]+\"))\n    throw new IllegalArgumentException(\"symlink has URI-unsafe characters: \" + s);\n  return s.isEmpty() ? null : s;\n}\n// use: path + (frag != null ? \"#\" + safeFragment(frag) : \"\")","typeGuard":"boolean isUriSafeLocalResource(Path p, String symlink) {\n  try {\n    new URI(p.toUri() + \"#\" + (symlink == null ? \"\" : symlink));\n    return true;\n  } catch (URISyntaxException e) { return false; }\n}","tryCatchPattern":null,"preventionTips":["Restrict distributed-cache symlink names and staged filenames to URI-safe characters","Encode programmatically built fragments with URLEncoder before joining with '#'","Validate every -libjars/-archives/-files entry with a new URI(...) round-trip in a preflight check","Reject filenames containing spaces or '#' at upload time rather than at job submission"],"tags":["hadoop","mapreduce","yarn","local-resource","uri","distributed-cache","escaping"],"backgroundTag":"uri-parse-failure","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}