{"record":{"id":"21b57b86aaa5f099","repo":"apache/seatunnel","slug":"file-s-does-not-exist","errorCode":null,"errorMessage":"File %s does not exist.","messagePattern":"File (.+?) does not exist\\.","errorType":"exception","errorClass":"FileNotFoundException","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":221,"sourceCode":"            boolean isDir = true;\n            int blockReplication = 1;\n            long blockSize = DEFAULT_BLOCK_SIZE; // Block Size not known.\n            long modTime = -1; // Modification time of root directory not known.\n            Path root = new Path(\"/\");\n            return new FileStatus(\n                    length,\n                    isDir,\n                    blockReplication,\n                    blockSize,\n                    modTime,\n                    root.makeQualified(this.getUri(), this.getWorkingDirectory()));\n        }\n        String pathName = parentPath.toUri().getPath();\n        Vector<LsEntry> sftpFiles;\n        try {\n            sftpFiles = (Vector<LsEntry>) client.ls(pathName);\n        } catch (SftpException e) {\n            throw new FileNotFoundException(String.format(E_FILE_NOTFOUND, file));\n        }\n        if (sftpFiles != null) {\n            for (LsEntry sftpFile : sftpFiles) {\n                if (sftpFile.getFilename().equals(file.getName())) {\n                    // file found in directory\n                    fileStat = getFileStatus(client, sftpFile, parentPath);\n                    break;\n                }\n            }\n            if (fileStat == null) {\n                throw new FileNotFoundException(String.format(E_FILE_NOTFOUND, file));\n            }\n        } else {\n            throw new FileNotFoundException(String.format(E_FILE_NOTFOUND, file));\n        }\n        return fileStat;\n    }\n","sourceCodeStart":203,"sourceCodeEnd":239,"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#L203-L239","documentation":"getFileStatus() lists the parent directory with client.ls(parentPath). If the ls call throws an SftpException, the code converts it into a FileNotFoundException(\"File %s does not exist.\"). Note this conflates real errors (permission denied on the parent dir, path is actually a file) with genuine non-existence, because any SftpException from ls becomes 'file does not exist'.","triggerScenarios":"ls() on the parent directory fails with any SftpException — e.g. permission denied (id 3), no such file (id 2) when the parent itself is missing, or the path points at a regular file so its 'parent listing' lookup behaves oddly.","commonSituations":"Parent directory unreadable by the SFTP user (missing +x/+r); typo in path so the parent dir is absent; checking status of a file inside a directory the account cannot traverse; chrooted users with restricted listings.","solutions":["Verify the parent directory exists and is readable/traversable by the SFTP user (ls it manually)","Check the exact path spelling and working directory (relative vs absolute path)","Grant the SFTP account read+execute on all ancestor directories","Distinguish the wrapped cause: if the original SftpException id is 3 (permission denied), fix permissions rather than assuming the file is missing","Use an absolute path to avoid surprises from a changed working directory"],"exampleFix":"// before\nFileStatus st = fs.getFileStatus(new Path(\"/data/out/file.txt\")); // parent /data/out unreadable -> FNFE\n// after\nif (!fs.exists(new Path(\"/data/out\"))) {\n    fs.mkdirs(new Path(\"/data/out\")); // ensure parent exists & is accessible\n}\nFileStatus st = fs.getFileStatus(new Path(\"/data/out/file.txt\"));","handlingStrategy":"validation","validationCode":"Path parent = path.getParent(); if (!fs.exists(parent)) throw new IllegalStateException(\"Parent missing: \" + parent); // also verify with manual sftp ls that the account can read it","typeGuard":null,"tryCatchPattern":"try { st = fs.getFileStatus(path); } catch (FileNotFoundException e) { /* treat as absent or fix parent perms */ }","preventionTips":["Grant read+execute on all ancestor directories","Use absolute paths","Verify paths manually with an sftp client under the same account","Distinguish permission-denied from true absence via the wrapped cause","Create parents with mkdirs before stat"],"tags":["sftp","filenotfound","ls","permissions"],"backgroundTag":"file-not-found","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"}