apache/seatunnel · error · IOException
SftpException wrapped (pwd failed while creating directory)
Error message
SftpException wrapped (pwd failed while creating directory)
What it means
In mkdirs(), the first step resolves the server working directory with client.pwd(); an SftpException here is wrapped in a plain IOException. Directory creation cannot proceed because the code cannot compute the absolute path of the directory to create.
Source
Thrown at seatunnel-connectors-v2/connector-file/connector-file-sftp/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sftp/system/SFTPFileSystem.java:307
}
private FsPermission getPermissions(LsEntry sftpFile) {
return new FsPermission((short) sftpFile.getAttrs().getPermissions());
}
/**
* Convenience method, so that we don't open a new connection when using this method from within
* another method. Otherwise every API invocation incurs the overhead of opening/closing a TCP
* connection.
*/
private boolean mkdirs(ChannelSftp client, Path file, FsPermission permission)
throws IOException {
boolean created = true;
Path workDir;
try {
workDir = new Path(client.pwd());
} catch (SftpException e) {
throw new IOException(e);
}
Path absolute = makeAbsolute(workDir, file);
String pathName = absolute.getName();
if (!exists(client, absolute)) {
Path parent = absolute.getParent();
created = parent == null || mkdirs(client, parent, FsPermission.getDefault());
if (created) {
String parentDir = parent.toUri().getPath();
boolean succeeded = true;
try {
final String previousCwd = client.pwd();
client.cd(parentDir);
LOG.debug("Creating directory " + pathName);
client.mkdir(pathName);
client.cd(previousCwd);
} catch (SftpException e) {
throw new IOException(String.format(E_MAKE_DIR_FORPATH, pathName, parentDir));
}View on GitHub (pinned to cf67b549a7)
Solutions
- Reconnect the SFTP channel and retry mkdirs
- Verify with an sftp client that pwd works for the account (chroot/restricted shell)
- Check server logs for realpath failures at the time of the job
- Ensure the channel/session is kept alive (SSH keepalive settings) during long jobs
- Pass absolute paths so pwd resolution is less critical, though pwd is still called internally
Example fix
// before
fs.mkdirs(new Path("/out/2026/09/10")); // throws if channel dead
// after
if (channel == null || !channel.isConnected()) {
channel = openConnectedChannel(conf);
}
fs.mkdirs(new Path("/out/2026/09/10")); Defensive patterns
Strategy: retry
Validate before calling
if (channel == null || !channel.isConnected()) { channel = openConnectedChannel(conf); } Try / catch
try { fs.mkdirs(path); } catch (IOException e) { reconnect(); fs.mkdirs(path); // single retry after refresh } Prevention
- Enable SSH keepalive
- Reconnect on any IOException before retry
- Probe pwd() at job start
- Test chrooted accounts interactively
- Reuse one healthy channel per job phase
When it happens
Trigger: mkdirs() (reached directly, from create()'s parent-creation, or recursively) runs on a dead/disconnected channel or a server that rejects the realpath request behind pwd().
Common situations: Connection dropped before a write step; session timed out between read and write phases; chrooted accounts whose server rejects realpath; channel reused after a prior operation threw and left it closed.
Related errors
- SftpException wrapped (pwd failed while resolving file statu
- Can't make directory for path "%s" under "%s".
- Can't make directory for path %s since it is a file.
- SftpException wrapped (pwd failed while deleting)
- SftpException wrapped (pwd failed while listing status)
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/100fcbd9e3cd2385.
Report an issue: GitHub.