apache/hadoop · error · IllegalArgumentException
Invalid parameter value: destination = "{str}" is not an abs
Error message
Invalid parameter value: destination = "{str}" is not an absolute path. What it means
DestinationParam validates the 'destination' query parameter carried by WebHDFS RENAME (and symlink-style) PUT requests. The validate() method at DestinationParam.java:30-43 treats null or "" as absent, but any non-empty value that does not start with Path.SEPARATOR ('/') is rejected with this IllegalArgumentException (HTTP 400). The value is then normalized via new Path(str).toUri().getPath(), so the library insists on fully-qualified absolute HDFS paths.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/DestinationParam.java:36
package org.apache.hadoop.hdfs.web.resources;
import org.apache.hadoop.fs.Path;
/** Destination path parameter. */
public class DestinationParam extends StringParam {
/** Parameter name. */
public static final String NAME = "destination";
/** Default parameter value. */
public static final String DEFAULT = "";
private static final Domain DOMAIN = new Domain(NAME, null);
private static String validate(final String str) {
if (str == null || str.equals(DEFAULT)) {
return null;
}
if (!str.startsWith(Path.SEPARATOR)) {
throw new IllegalArgumentException("Invalid parameter value: " + NAME
+ " = \"" + str + "\" is not an absolute path.");
}
return new Path(str).toUri().getPath();
}
/**
* Constructor.
* @param str a string representation of the parameter value.
*/
public DestinationParam(final String str) {
super(DOMAIN, validate(str));
}
@Override
public String getName() {
return NAME;
}
}View on GitHub (pinned to 2add963021)
Solutions
- Prefix the destination with '/' so it is absolute from the HDFS root, e.g. destination=/dir2/newname.
- Build the parameter from a qualified Path: path.makeQualified(fs.getUri(), fs.getWorkingDirectory()).toUri().getPath().
- Use FileSystem.rename() via the webhdfs:// client, which constructs DestinationParam for you.
- URL-encode the destination after making it absolute (spaces, '%', etc.).
Example fix
// before String dest = newPathName; // e.g. "dir2/newname" String url = base + "?op=RENAME&destination=" + dest; // after String dest = "/" + rootDir + "/" + newPathName; // "/data/dir2/newname" String url = base + "?op=RENAME&destination=" + URLEncoder.encode(dest, "UTF-8");
Defensive patterns
Strategy: validation
Validate before calling
static String checkedDestination(String root, String dest) {
Path p = new Path(root, dest).makeQualified(new Path(root).toUri(), new Path("/"));
String abs = p.toUri().getPath();
if (!abs.startsWith("/")) throw new IllegalArgumentException("destination must be absolute: " + abs);
return abs;
} Type guard
static boolean isAbsoluteHdfsPath(String s) { return s != null && !s.isEmpty() && s.startsWith("/"); } Try / catch
try {
fs.rename(src, new Path(root, name)); // webhdfs client builds DestinationParam
} catch (IOException e) {
if (e.getMessage() != null && e.getMessage().contains("is not an absolute path")) {
// recompute destination as absolute and retry once
}
} Prevention
- Never pass Path.getFileName() output as 'destination'; always qualify against the parent/root first.
- Keep a helper that joins root + relative and asserts the leading '/'.
- URL-encode the destination after validation.
When it happens
Trigger: PUT ?op=RENAME&destination=dir2/newname (relative path, no leading '/'); destination built from a bare filename such as destination=file2.txt; destination containing a URL-encoded relative path after decode; sending destination= (empty is OK, it becomes null) but destination=. or destination=.. fails.
Common situations: Building the destination from Path.getFileName() or a relative Path.toString() instead of the full path; scripts that join path segments without a leading separator; porting code from a FileSystem.rename(src, dst) call where dst was relative to the working directory (WebHDFS has no working-directory context for the parameter).
Related errors
- The source {} and destination {} are the same
- rename destination cannot be the root
- Rename destination {} is a directory or file under source {}
- {str} is not a valid DELETE operation.
- {str} is not a valid GET operation.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/6c281b0945752d46.
Report an issue: GitHub.