apache/hadoop · error · IllegalArgumentException
Error parsing argument. Argument must be a valid URI: {}
Error message
Error parsing argument. Argument must be a valid URI: {} What it means
JobResourceUploader.stringToPath(s) converts a resource string to a Path by parsing it with new URI(s) and keeping only scheme/authority/path (dropping fragments and queries). It runs during submission over cache-file/archive/libjar URIs, shared-cache libjar results, and the job jar path (mapreduce.job.jar) while the LimitChecker walks resources. Any string that java.net.URI rejects is rethrown as IllegalArgumentException('Error parsing argument. Argument must be a valid URI: <s>').
Source
Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobResourceUploader.java:544
explorePath(conf, stringToPath(uri), limitChecker, statCache);
}
if (jobJar != null) {
explorePath(conf, stringToPath(jobJar), limitChecker, statCache);
}
}
/**
* Convert a String to a Path and gracefully remove fragments/queries if they
* exist in the String.
*/
@VisibleForTesting
Path stringToPath(String s) {
try {
URI uri = new URI(s);
return new Path(uri.getScheme(), uri.getAuthority(), uri.getPath());
} catch (URISyntaxException e) {
throw new IllegalArgumentException(
"Error parsing argument." + " Argument must be a valid URI: " + s, e);
}
}
@VisibleForTesting
protected static final String MAX_RESOURCE_ERR_MSG =
"This job has exceeded the maximum number of submitted resources";
@VisibleForTesting
protected static final String MAX_TOTAL_RESOURCE_MB_ERR_MSG =
"This job has exceeded the maximum size of submitted resources";
@VisibleForTesting
protected static final String MAX_SINGLE_RESOURCE_MB_ERR_MSG =
"This job has exceeded the maximum size of a single submitted resource";
private static class LimitChecker {
LimitChecker(Configuration conf) {
this.maxNumOfResources =
conf.getInt(MRJobConfig.MAX_RESOURCES,View on GitHub (pinned to 2add963021)
Solutions
- Set paths through Path/URI round-trips: conf.set(MRJobConfig.JAR, new Path(jarPath).toUri().toString())
- Move builds out of directories containing spaces or reserved characters
- Encode components manually (%20) if a raw string is unavoidable
- Unit-test your driver's conf with new URI(conf.get(...)) for every cache/jar value before deploying
Example fix
// before
conf.set("mapreduce.job.jar", "/build/my project/app.jar"); // space -> not a URI
// after
conf.set("mapreduce.job.jar", new Path("/build/my project/app.jar").toUri().toString());
// -> file:/build/my%20project/app.jar Defensive patterns
Strategy: validation
Validate before calling
// round-trip every shipped resource string through Path before setting it
String jar = new Path(rawJarPath).toUri().toString(); // encodes spaces etc.
conf.set(MRJobConfig.JAR, jar);
for (String s : resourceStrings) {
new URI(s); // throws early with your own context if invalid
} Type guard
static boolean isValidCacheUri(String s) {
try { new URI(s); return true; }
catch (URISyntaxException e) { return false; }
} Prevention
- Build in spaces-free paths, or always normalize with Path.toUri()
- Never set mapreduce.job.jar or cache entries from raw concatenated strings
- Add a unit test that URI-parses every path your driver puts in the conf
When it happens
Trigger: A job jar built in a directory containing spaces (e.g. target dir 'my project/'), so the mapreduce.job.jar value is not a valid URI; cache entries added as raw filesystem strings through job.setCacheFiles? (must be URIs anyway); values that were never pre-validated because they bypassed the -files/-libjars parsing path and reach size-exploration directly.
Common situations: Building in a workspace path with spaces on Windows/macOS; third-party wrappers setting cache options programmatically from raw strings; shared-cache-enabled clusters reprocessing URIs that were fine as strings but not as URIs.
Related errors
- Error parsing files argument. Argument must be a valid URI:
- Error parsing archives argument. Argument must be a valid UR
- Error processing URI
- Error parsing local resource path. Path was not able to be c
- Invalid specification for distributed-cache artifacts of typ
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/0f5b4b90b91ce3a3.
Report an issue: GitHub.