{"record":{"id":"9a48811b6d57f977","repo":"apache/hadoop","slug":"file-conflicts","errorCode":null,"errorMessage":"file conflicts: {}","messagePattern":"file conflicts: (.+?)","errorType":"exception","errorClass":"FileConflictException","httpStatus":null,"severity":"error","filePath":"hadoop-cloud-storage-project/hadoop-huaweicloud/src/main/java/org/apache/hadoop/fs/obs/OBSPosixBucketUtils.java","lineNumber":690,"sourceCode":"      } else {\n        LOG.debug(\n            \"Found file (with /): real file? should not happen: {}\",\n            key);\n        return new OBSFileStatus(\n            meta.getContentLength(),\n            OBSCommonUtils.dateToLong(meta.getLastModified()),\n            path,\n            owner.getDefaultBlockSize(path),\n            owner.getUsername());\n      }\n    } catch (ObsException e) {\n      if (e.getResponseCode() == OBSCommonUtils.NOT_FOUND_CODE) {\n        LOG.debug(\"Not Found: {}\", path);\n        throw new FileNotFoundException(\n            \"No such file or directory: \" + path);\n      }\n      if (e.getResponseCode() == OBSCommonUtils.CONFLICT_CODE) {\n        throw new FileConflictException(\n            \"file conflicts: \" + e.getResponseStatus());\n      }\n      throw OBSCommonUtils.translateException(\"getFileStatus\", path, e);\n    }\n  }\n\n  static ContentSummary fsGetDirectoryContentSummary(\n      final OBSFileSystem owner,\n      final String key) throws IOException {\n    String newKey = key;\n    newKey = OBSCommonUtils.maybeAddTrailingSlash(newKey);\n    long[] summary = {0, 0, 1};\n    LOG.debug(\"Summary key {}\", newKey);\n    ListObjectsRequest request = new ListObjectsRequest();\n    request.setBucketName(owner.getBucket());\n    request.setPrefix(newKey);\n    request.setMaxKeys(owner.getMaxKeys());\n    ObjectListing objects = OBSCommonUtils.listObjects(owner, request);","sourceCodeStart":672,"sourceCodeEnd":708,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-huaweicloud/src/main/java/org/apache/hadoop/fs/obs/OBSPosixBucketUtils.java#L672-L708","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nFileStatus st = fs.getFileStatus(new Path(\"/data/x\"));\n\n// after\ntry {\n  FileStatus st = fs.getFileStatus(new Path(\"/data/x\"));\n} catch (FileConflictException e) {\n  // remove the losing form, keep the intended one\n  fs.delete(new Path(\"/data/x\"), true); // drop folder form, then rewrite file\n  ... // recreate /data/x as a file and retry\n}","handlingStrategy":"try-catch","validationCode":"// detect both forms before stat fails\nboolean hasFile = fs.util().exists(fs.makeQualified(p));\nboolean hasDir = fs.util().exists(fs.makeQualified(new Path(p + \"/\")));\nif (hasFile && hasDir) {\n  // resolve the name collision before calling getFileStatus\n}","typeGuard":null,"tryCatchPattern":"try {\n  return fs.getFileStatus(p);\n} catch (FileConflictException e) {\n  // file and folder share the name: remove the unintended form, then retry\n}","preventionTips":["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"],"tags":["hadoop","obs","posix","name-conflict","getfilestatus"],"backgroundTag":"file-directory-name-conflict","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}