{"record":{"id":"d0a0d1e7ccb6bb03","repo":"apache/hadoop","slug":"failed-to-create-directory-d0a0d1","errorCode":null,"errorMessage":"failed to create directory {}","messagePattern":"failed to create directory (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java","lineNumber":1011,"sourceCode":"    final DFSClient dfs = new DFSClient(DFSUtilClient.getNNAddress(conf), conf);\n    final String fullName = file.getFullName(parent);\n    OutputStream fos = null;\n    try {\n      if (!lfInited) {\n        lostFoundInit(dfs);\n      }\n      if (!lfInitedOk) {\n        throw new IOException(\"failed to initialize lost+found\");\n      }\n      String target = lostFound + fullName;\n      if (hdfsPathExists(target)) {\n        LOG.warn(\"Fsck: can't copy the remains of \" + fullName + \" to \" +\n          \"lost+found, because \" + target + \" already exists.\");\n        return;\n      }\n      if (!namenode.getRpcServer().mkdirs(\n          target, file.getPermission(), true)) {\n        throw new IOException(\"failed to create directory \" + target);\n      }\n      // create chains\n      int chain = 0;\n      boolean copyError = false;\n      for (LocatedBlock lBlk : blocks.getLocatedBlocks()) {\n        LocatedBlock lblock = lBlk;\n        DatanodeInfo[] locs = lblock.getLocations();\n        if (locs == null || locs.length == 0) {\n          if (fos != null) {\n            fos.flush();\n            fos.close();\n            fos = null;\n          }\n          continue;\n        }\n        if (fos == null) {\n          fos = dfs.create(target + \"/\" + chain, true);\n          chain++;","sourceCodeStart":993,"sourceCodeEnd":1029,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeFsck.java#L993-L1029","documentation":"Error \"failed to create directory {}\" thrown in apache/hadoop.","triggerScenarios":"fsck fails to create a target directory (e.g., lost+found subdirectories).","commonSituations":"Insufficient privileges or safemode during fsck's directory creation steps.","solutions":["Check permissions on the parent path and NameNode safemode state, then retry directory creation."],"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"}