{"record":{"id":"412895c58bbed9f4","repo":"apache/seatunnel","slug":"can-t-make-directory-for-path-s-under-s","errorCode":null,"errorMessage":"Can't make directory for path \"%s\" under \"%s\".","messagePattern":"Can't make directory for path \"(.+?)\" under \"(.+?)\"\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-file/connector-file-sftp/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sftp/system/SFTPFileSystem.java","lineNumber":324,"sourceCode":"        } catch (SftpException e) {\n            throw new IOException(e);\n        }\n        Path absolute = makeAbsolute(workDir, file);\n        String pathName = absolute.getName();\n        if (!exists(client, absolute)) {\n            Path parent = absolute.getParent();\n            created = parent == null || mkdirs(client, parent, FsPermission.getDefault());\n            if (created) {\n                String parentDir = parent.toUri().getPath();\n                boolean succeeded = true;\n                try {\n                    final String previousCwd = client.pwd();\n                    client.cd(parentDir);\n                    LOG.debug(\"Creating directory \" + pathName);\n                    client.mkdir(pathName);\n                    client.cd(previousCwd);\n                } catch (SftpException e) {\n                    throw new IOException(String.format(E_MAKE_DIR_FORPATH, pathName, parentDir));\n                }\n                created = created & succeeded;\n            }\n        } else if (isFile(client, absolute)) {\n            throw new IOException(String.format(E_DIR_CREATE_FROMFILE, absolute));\n        } else {\n            LOG.debug(\"Skipping creation of existing directory \" + file);\n        }\n        if (!created) {\n            LOG.debug(\"Failed to create \" + file);\n        }\n        return created;\n    }\n\n    private boolean isFile(ChannelSftp channel, Path file) throws IOException {\n        try {\n            return !getFileStatus(channel, file).isDirectory();\n        } catch (FileNotFoundException e) {","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-file/connector-file-sftp/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sftp/system/SFTPFileSystem.java#L306-L342","documentation":"mkdirs() attempts to create the leaf directory by cd'ing to the parent and calling client.mkdir(pathName). Any SftpException from that sequence is converted to IOException(\"Can't make directory for path \\\"%s\\\" under \\\"%s\\\".\") — the SFTP server refused the MKDIR, typically because of permissions or because the entry already exists.","triggerScenarios":"client.mkdir() fails with permission denied (SFTP id 3), failure (id 4), or the directory already exists on servers that error instead of succeeding; also cd() to the parent failing mid-sequence.","commonSituations":"SFTP user lacks write permission on the parent directory; quota/disk-full on the server; concurrent jobs creating the same directory; read-only mounts on the server side.","solutions":["Grant the SFTP user write permission on the parent directory","Check the server for quota or disk-space limits","Handle 'already exists' benignly: verify with exists() before/after and ignore id-4 conflicts if the dir is present","Ensure no concurrent jobs race to create the same path, or serialize creation","Check the wrapped SftpException id in server/client logs for the precise cause"],"exampleFix":"// before\nfs.mkdirs(new Path(\"/data/out\")); // permission denied on /data\n// after\n// grant write on server: chown sftpuser /data && chmod u+w /data\nchmod u+w /data\nfs.mkdirs(new Path(\"/data/out\"));","handlingStrategy":"try-catch","validationCode":"// pre-flight: ensure parent writable by the account; server-side: sudo -u sftpuser test -w /data/parent\nPath parent = path.getParent(); if (!fs.exists(parent)) fs.mkdirs(parent);","typeGuard":null,"tryCatchPattern":"try { fs.mkdirs(p); } catch (IOException e) { if (fs.exists(p) && fs.getFileStatus(p).isDirectory()) { /* benign race: already created */ } else { throw e; } }","preventionTips":["Grant write permission on parent dirs","Check server quota/disk space","Serialize concurrent jobs creating the same dir","Inspect SftpException id 3 (perm) vs 4 (failure)","Pre-create directory trees during setup"],"tags":["sftp","mkdir","permission-denied"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}