apache/hadoop · error · FileConflictException
file conflicts: {}
Error message
file conflicts: {} What it means
In the POSIX getFileStatus, an ObsException with response code CONFLICT is surfaced as FileConflictException('file conflicts: <responseStatus>'). A 409 on a stat call means the bucket holds both a file and a folder under the same name (or the name exists in both forms), so no single FileStatus can be returned.
Source
Thrown at hadoop-cloud-storage-project/hadoop-huaweicloud/src/main/java/org/apache/hadoop/fs/obs/OBSPosixBucketUtils.java:690
} else {
LOG.debug(
"Found file (with /): real file? should not happen: {}",
key);
return new OBSFileStatus(
meta.getContentLength(),
OBSCommonUtils.dateToLong(meta.getLastModified()),
path,
owner.getDefaultBlockSize(path),
owner.getUsername());
}
} catch (ObsException e) {
if (e.getResponseCode() == OBSCommonUtils.NOT_FOUND_CODE) {
LOG.debug("Not Found: {}", path);
throw new FileNotFoundException(
"No such file or directory: " + path);
}
if (e.getResponseCode() == OBSCommonUtils.CONFLICT_CODE) {
throw new FileConflictException(
"file conflicts: " + e.getResponseStatus());
}
throw OBSCommonUtils.translateException("getFileStatus", path, e);
}
}
static ContentSummary fsGetDirectoryContentSummary(
final OBSFileSystem owner,
final String key) throws IOException {
String newKey = key;
newKey = OBSCommonUtils.maybeAddTrailingSlash(newKey);
long[] summary = {0, 0, 1};
LOG.debug("Summary key {}", newKey);
ListObjectsRequest request = new ListObjectsRequest();
request.setBucketName(owner.getBucket());
request.setPrefix(newKey);
request.setMaxKeys(owner.getMaxKeys());
ObjectListing objects = OBSCommonUtils.listObjects(owner, request);View on GitHub (pinned to 2add963021)
Solutions
- Decide which form should win and delete the other explicitly by its full key (file versus directory object)
- Stop mixing object-mode and POSIX-mode access patterns on one bucket
- Retry after cleaning the conflicting name; if it persists, inspect the bucket with the provider console or CLI
Example fix
// before
FileStatus st = fs.getFileStatus(new Path("/data/x"));
// after
try {
FileStatus st = fs.getFileStatus(new Path("/data/x"));
} catch (FileConflictException e) {
// remove the losing form, keep the intended one
fs.delete(new Path("/data/x"), true); // drop folder form, then rewrite file
... // recreate /data/x as a file and retry
} Defensive patterns
Strategy: try-catch
Validate before calling
// detect both forms before stat fails
boolean hasFile = fs.util().exists(fs.makeQualified(p));
boolean hasDir = fs.util().exists(fs.makeQualified(new Path(p + "/")));
if (hasFile && hasDir) {
// resolve the name collision before calling getFileStatus
} Try / catch
try {
return fs.getFileStatus(p);
} catch (FileConflictException e) {
// file and folder share the name: remove the unintended form, then retry
} Prevention
- Do not mix object-mode and POSIX-mode clients on one bucket
- Define naming rules that keep files and folders from colliding
- After interrupted renames, check for name collisions before reading
When it happens
Trigger: A POSIX OBS bucket where an object and a directory marker share one key; concurrent mkdir and create of the same name; mixing object-mode and POSIX-mode clients on a single bucket so both forms get written.
Common situations: Flat-object writers (s3a-style keys) and POSIX writers used against the same bucket; leftovers from an interrupted rename; migration tools that copy files and folders with identical names.
Related errors
- No such file or directory: {}
- {} is not a directory
- No such file or directory: {}
- File conflicts during rename, {}
- {path}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/9a48811b6d57f977.
Report an issue: GitHub.