{"record":{"id":"ba45c6f4f29db1a4","repo":"apache/hadoop","slug":"path-is-a-file-dir","errorCode":null,"errorMessage":"Path is a file: \" + dir","messagePattern":"Path is a file: \" \\+ dir","errorType":"exception","errorClass":"FileAlreadyExistsException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/MkdirOperation.java","lineNumber":139,"sourceCode":"    if (dir.isRoot()) {\n      // fast exit for root.\n      return true;\n    }\n\n    // get the file status of the path.\n    // this is done even for a magic path, to avoid always  issuing PUT\n    // requests. Doing that without a check wouild seem to be an\n    // optimization, but it is not because\n    // 1. PUT is slower than HEAD\n    // 2. Write capacity is less than read capacity on a shard\n    // 3. It adds needless entries in versioned buckets, slowing\n    //    down subsequent operations.\n    FileStatus fileStatus = getPathStatusExpectingDir(dir);\n    if (fileStatus != null) {\n      if (fileStatus.isDirectory()) {\n        return true;\n      } else {\n        throw new FileAlreadyExistsException(\"Path is a file: \" + dir);\n      }\n    }\n    // file status was null\n\n    // is the path magic?\n    // If so, we declare success without looking any further\n    if (isMagicPath) {\n      // Create the marker file immediately,\n      callbacks.createFakeDirectory(dir);\n      return true;\n    }\n\n    // if performance creation mode is set, no need to check\n    // whether the closest ancestor is dir.\n    if (!performanceMkdir) {\n      verifyFileStatusOfClosestAncestor();\n    }\n","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/MkdirOperation.java#L121-L157","documentation":"Error \"Path is a file: \" + dir\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/MkdirOperation.java:139 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a different path for the directory; a file already exists at that location."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}