{"record":{"id":"a2e60a81df0cbab3","repo":"apache/seatunnel","slug":"failed-to-get-file-status","errorCode":null,"errorMessage":"Failed to get file status","messagePattern":"Failed to get file 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":158,"sourceCode":"        connectionPool.disconnect(channel);\n    }\n\n    private Path makeAbsolute(Path workDir, Path path) {\n        if (path.isAbsolute()) {\n            return path;\n        }\n        return new Path(workDir, path);\n    }\n\n    private boolean exists(ChannelSftp channel, Path file) throws IOException {\n        try {\n            getFileStatus(channel, file);\n            return true;\n        } catch (FileNotFoundException fnfe) {\n            LOG.debug(\"File does not exist: \" + file, fnfe);\n            return false;\n        } catch (IOException ioe) {\n            throw new IOException(E_FILE_STATUS, ioe);\n        }\n    }\n\n    public String quote(String path) {\n        byte[] _path = path.getBytes(StandardCharsets.UTF_8);\n        int count = 0;\n        for (int i = 0; i < _path.length; i++) {\n            byte b = _path[i];\n            if (b == '\\\\' || b == '?' || b == '*') {\n                count++;\n            }\n        }\n        if (count == 0) {\n            return path;\n        }\n        byte[] _path2 = new byte[_path.length + count];\n        for (int i = 0, j = 0; i < _path.length; i++) {\n            byte b = _path[i];","sourceCodeStart":140,"sourceCodeEnd":176,"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#L140-L176","documentation":"SFTPFileSystem.exists() resolves a path via getFileStatus(); a FileNotFoundException means the path genuinely does not exist (returns false), but any other IOException from the SFTP layer (connection issues, SftpException on pwd/ls/stat) is rethrown wrapped as 'Failed to get file status'. It signals the caller could not determine existence due to an SFTP communication problem, not that the file is absent.","triggerScenarios":"exists() is called (directly or via mkdirs, rename, create) while the SFTP channel is broken/disconnected, the server rejects the pwd() command, or the underlying stat/ls raises a non-FileNotFound SftpException (e.g. permission failure).","commonSituations":"SFTP session dropped mid-job after network hiccup or server idle timeout; user lacks permission to list the parent directory; wrong working directory after cd; SSH server intermittently closing channels.","solutions":["Verify the SFTP connection is still alive and reconnect if the session was dropped","Check that the SFTP user has read/execute permission on the parent directory of the path","Test pwd()/ls() manually with an sftp client using the same credentials to reproduce the failure","Wrap long-running jobs with periodic keepalive or re-establish the FileSystem connection before exists()","Inspect the wrapped cause (ioe.getCause()) to identify the exact SftpException id"],"exampleFix":"// before\nboolean ok = fs.exists(path); // throws IOException 'Failed to get file status'\n// after\nboolean ok;\ntry {\n    ok = fs.exists(path);\n} catch (IOException e) {\n    LOG.warn(\"Existence check failed, reconnecting\", e);\n    fs = reconnectFileSystem(conf); // re-open SFTP connection\n    ok = fs.exists(path);\n}","handlingStrategy":"try-catch","validationCode":"if (channel == null || !channel.isConnected()) { channel = reconnect(conf); }","typeGuard":null,"tryCatchPattern":"try { boolean ok = fs.exists(path); } catch (IOException e) { LOG.error(\"SFTP status check failed for {}\", path, e); throw new UncheckedIOException(e); }","preventionTips":["Check channel.isConnected() before operations","Enable SSH keepalive to avoid idle drops","Use absolute paths","Verify SFTP account permissions on parent dirs","Inspect the wrapped cause for the SftpException id"],"tags":["sftp","ioexception","file-status","network"],"backgroundTag":"file-read-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}