{"record":{"id":"7a204e0704eaa318","repo":"apache/seatunnel","slug":"sftpexception-wrapped-pwd-failed-while-listing-st","errorCode":null,"errorMessage":"SftpException wrapped (pwd failed while listing status)","messagePattern":"SftpException wrapped \\(pwd failed while listing status\\)","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":409,"sourceCode":"            } catch (SftpException e) {\n                status = false;\n            }\n            return status;\n        }\n    }\n\n    /**\n     * Convenience method, so that we don't open a new connection when using this method from within\n     * another method. Otherwise every API invocation incurs the overhead of opening/closing a TCP\n     * connection.\n     */\n    @SuppressWarnings(\"unchecked\")\n    private FileStatus[] listStatus(ChannelSftp client, Path file) throws IOException {\n        Path workDir;\n        try {\n            workDir = new Path(client.pwd());\n        } catch (SftpException e) {\n            throw new IOException(e);\n        }\n        Path absolute = makeAbsolute(workDir, file);\n        FileStatus fileStat = getFileStatus(client, absolute);\n        if (!fileStat.isDirectory()) {\n            return new FileStatus[] {fileStat};\n        }\n        Vector<LsEntry> sftpFiles;\n        try {\n            sftpFiles = (Vector<LsEntry>) client.ls(absolute.toUri().getPath());\n        } catch (SftpException e) {\n            throw new IOException(e);\n        }\n        ArrayList<FileStatus> fileStats = new ArrayList<FileStatus>();\n        for (int i = 0; i < sftpFiles.size(); i++) {\n            LsEntry entry = sftpFiles.get(i);\n            String fname = entry.getFilename();\n            // skip current and parent directory, ie. \".\" and \"..\"\n            if (!\".\".equalsIgnoreCase(fname) && !\"..\".equalsIgnoreCase(fname)) {","sourceCodeStart":391,"sourceCodeEnd":427,"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#L391-L427","documentation":"listStatus() starts by resolving the remote working directory with client.pwd(); a failing pwd is rethrown as a bare IOException wrapping the SftpException. The list operation never reached the actual directory read — the channel was already unusable or the server rejected the pwd request.","triggerScenarios":"Any call that lists status (listStatus, and indirectly getFileStatus/exists/delete paths that call it) when the SFTP channel is disconnected, unauthenticated, or the server errors on pwd.","commonSituations":"Long-running jobs whose SFTP sessions timed out; connection pool handing out stale channels; network/NAT drop; server restarted between connect and list.","solutions":["Re-establish the SFTP connection (connect()) and retry the list","Add SSH keep-alive to prevent idle channel death","Verify credentials/session validity before long operations","Check the wrapped SftpException id to determine server-side vs transport failure"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// probe channel health before heavy operations\ntry { fs.exists(new Path(\"/\")); } catch (IOException e) { reconnect(); }","typeGuard":null,"tryCatchPattern":"try {\n    FileStatus[] st = fs.listStatus(path);\n} catch (IOException e) {\n    if (e.getCause() instanceof SftpException) { reconnect(); /* retry once */ }\n    throw e;\n}","preventionTips":["Set ServerAliveInterval on the SSH client","Avoid holding SFTP channels across long idle periods","Reconnect on any SftpException cause before retrying"],"tags":["sftp","io","connection"],"backgroundTag":"connection-refused","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"}