apache/hadoop · error · RenameFailedException
destination has no parent
Error message
destination has no parent
What it means
In checkDestinationParent, when getFileStatus on the destination parent raises FileNotFoundException, the code converts it to RenameFailedException('destination has no parent ') (note the trailing space in the message). Hadoop rename never creates missing intermediate directories, so every ancestor of the destination must already exist as a directory.
Source
Thrown at hadoop-cloud-storage-project/hadoop-huaweicloud/src/main/java/org/apache/hadoop/fs/obs/OBSObjectBucketUtils.java:200
return true;
}
private static void checkDestinationParent(final OBSFileSystem owner,
final Path src,
final Path dst) throws IOException {
Path parent = dst.getParent();
if (!OBSCommonUtils.pathToKey(owner, parent).isEmpty()) {
try {
FileStatus dstParentStatus = owner.getFileStatus(
dst.getParent());
if (!dstParentStatus.isDirectory()) {
throw new ParentNotDirectoryException(
"destination parent [" + dst.getParent()
+ "] is not a directory");
}
} catch (FileNotFoundException e2) {
throw new RenameFailedException(src, dst,
"destination has no parent ");
}
}
}
/**
* Implement rename file.
*
* @param owner OBS File System instance
* @param srcKey source object key
* @param dstKey destination object key
* @param srcStatus source object status
* @throws IOException any problem with rename operation
*/
private static void renameFile(final OBSFileSystem owner,
final String srcKey,
final String dstKey,
final FileStatus srcStatus)View on GitHub (pinned to 2add963021)
Solutions
- Create the parent chain before the rename: fs.mkdirs(dst.getParent())
- Fix the path construction that omits or misspells an intermediate directory
- Verify the bucket layout with listStatus on the parent prefix before moving data
Example fix
// before
fs.rename(src, new Path("/outputs/2024/01/data")); // /outputs/2024 does not exist
// after
Path dst = new Path("/outputs/2024/01/data");
fs.mkdirs(dst.getParent());
fs.rename(src, dst); Defensive patterns
Strategy: validation
Validate before calling
Path parent = dst.getParent();
if (parent != null && !fs.exists(parent)) {
fs.mkdirs(parent); // Hadoop rename does not create parents
} Try / catch
try {
fs.rename(src, dst);
} catch (RenameFailedException e) {
if (e.getMessage().trim().equals("destination has no parent")) {
fs.mkdirs(dst.getParent());
fs.rename(src, dst); // retry once after creating the chain
} else {
throw e;
}
} Prevention
- Always mkdirs the destination parent before rename on object stores
- Log and inspect computed destination paths for missing components
- Do not port HDFS assumptions: object-store rename never creates directories
When it happens
Trigger: fs.rename(src, '/a/b/c/file') when /a/b does not exist; moving data into a newly configured bucket whose directory tree was never created; output paths built with a missing or misspelled intermediate component.
Common situations: Jobs ported from HDFS where the framework pre-created output directories; first run against a fresh bucket; path templates that drop a component for edge-case values (e.g., empty partition field).
Related errors
- destination parent [{}] is not a directory
- {} is not a directory
- {} is root directory
- new destination is an existed directory
- new destination is an existed file
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/0fd14032efd6b0d1.
Report an issue: GitHub.