{"record":{"id":"16e7b4500f4d8c61","repo":"apache/hadoop","slug":"error-parsing-archives-argument-argument-must-be","errorCode":null,"errorMessage":"Error parsing archives argument. Argument must be a valid URI: {}","messagePattern":"Error parsing archives argument\\. Argument must be a valid 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":377,"sourceCode":"      }\n    }\n  }\n\n  @VisibleForTesting\n  void uploadArchives(Job job, Collection<String> archives,\n      Path submitJobDir, FsPermission mapredSysPerms, short submitReplication,\n      Map<String, Boolean> archiveSCUploadPolicies,\n      Map<URI, FileStatus> statCache) throws IOException {\n    Configuration conf = job.getConfiguration();\n    Path archivesDir = JobSubmissionFiles.getJobDistCacheArchives(submitJobDir);\n    if (!archives.isEmpty()) {\n      mkdirs(jtFs, archivesDir, mapredSysPerms);\n      for (String tmpArchives : archives) {\n        URI tmpURI;\n        try {\n          tmpURI = new URI(tmpArchives);\n        } catch (URISyntaxException e) {\n          throw new IllegalArgumentException(\"Error parsing archives argument.\"\n              + \" Argument must be a valid URI: \" + tmpArchives, e);\n        }\n        Path tmp = new Path(tmpURI);\n        URI newURI = null;\n        boolean uploadToSharedCache = false;\n        if (scConfig.isSharedCacheArchivesEnabled()) {\n          newURI = useSharedCache(tmpURI, tmp.getName(), statCache, conf, true);\n          if (newURI == null) {\n            uploadToSharedCache = true;\n          }\n        }\n\n        if (newURI == null) {\n          Path newPath =\n              copyRemoteFiles(archivesDir, tmp, conf, submitReplication);\n          try {\n            newURI = getPathURI(newPath, tmpURI.getFragment());\n          } catch (URISyntaxException ue) {","sourceCodeStart":359,"sourceCodeEnd":395,"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#L359-L395","documentation":"The -archives variant of the URI guard: for each archive entry (conf 'tmparchives'), JobResourceUploader builds java.net.URI before upload or shared-cache lookup. Malformed entries (raw spaces, backslashes, reserved characters) raise URISyntaxException, rethrown as IllegalArgumentException('Error parsing archives argument. Argument must be a valid URI: <entry>').","triggerScenarios":"-archives 'my models.tar.gz' with an unencoded space; Windows paths with backslashes; archive paths containing '[' ']' from date-stamped directories; entries with '#' fragments whose base part is malformed.","commonSituations":"Shipping ML model bundles or native libs as archives with human-readable names; unquoted shell variables; Mac/Windows local paths pasted into -archives.","solutions":["URL-encode illegal characters: -archives file:///opt/my%20models.tar.gz","Build entries in code with new Path(raw).toUri() and job.addCacheArchive(uri)","Use forward-slash file URIs on Windows","Loop-validate all entries with new URI(...) before submit() and report which one fails"],"exampleFix":"# before\nhadoop jar app.jar Driver -archives \"/data/my archive.tar.gz\" in out\n# -> IllegalArgumentException: Error parsing archives argument.\n\n# after\nhadoop jar app.jar Driver -archives \"/data/my%20archive.tar.gz\" in out","handlingStrategy":"validation","validationCode":"// validate every -archives entry before submit\nfor (String entry : StringUtils.getStrings(conf.get(\"tmparchives\"))) {\n  try {\n    new URI(entry);\n  } catch (URISyntaxException e) {\n    throw new IllegalArgumentException(\"-archives entry is not a valid URI: \" + entry, e);\n  }\n}","typeGuard":"static boolean isValidCacheUri(String s) {\n  try { new URI(s); return true; }\n  catch (URISyntaxException e) { return false; }\n}","tryCatchPattern":null,"preventionTips":["URL-encode spaces in archive names (%20)","Add archives programmatically with job.addCacheArchive(new Path(raw).toUri())","Avoid date-stamped directories containing reserved characters like '[' ']' in cache entries"],"tags":["distributed-cache","uri","archives-option","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"}