{"record":{"id":"954cde588a3db369","repo":"MuntashirAkon/AppManager","slug":"path-does-not-exist-virtualfilesystem","errorCode":null,"errorMessage":"+ path + does not exist.","messagePattern":"\\+ path \\+ does not exist\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/io/fs/VirtualFileSystem.java","lineNumber":968,"sourceCode":"    public void setUidGid(String path, int uid, int gid) {\n        // TODO: 7/12/22 This should either throw ErrnoException or a boolean value\n        checkMounted();\n    }\n\n    public boolean createLink(String link, String target, boolean soft) {\n        checkMounted();\n        return false;\n    }\n\n    /* I/O APIs */\n    @NonNull\n    public FileInputStream newInputStream(String path) throws IOException {\n        if (!checkAccess(path, OsConstants.R_OK)) {\n            throw new IOException(path + \" is inaccessible.\");\n        }\n        Node<?> targetNode = getNode(path);\n        if (targetNode == null) {\n            throw new FileNotFoundException(path + \" does not exist.\");\n        }\n        if (!targetNode.isFile()) {\n            throw new IOException(path + \" is not a file.\");\n        }\n        return new FileInputStream(getCachedFile(targetNode, false));\n    }\n\n    @NonNull\n    public FileOutputStream newOutputStream(String path, boolean append) throws IOException {\n        if (!checkAccess(path, OsConstants.W_OK)) {\n            throw new IOException(path + \" is inaccessible.\");\n        }\n        Node<?> targetNode = getNode(path);\n        if (targetNode == null) {\n            throw new FileNotFoundException(path + \" does not exist.\");\n        }\n        if (!targetNode.isFile()) {\n            throw new IOException(path + \" is not a file.\");","sourceCodeStart":950,"sourceCodeEnd":986,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/io/fs/VirtualFileSystem.java#L950-L986","documentation":"VirtualFileSystem.newInputStream(path) throws FileNotFoundException when getNode(path) returns null, i.e. the path does not resolve to a node in this virtual filesystem. The library requires the target to exist (and be a readable file) before opening an input stream. Unlike java.io.FileInputStream, existence is checked against the VFS tree, not the raw OS filesystem.","triggerScenarios":"Calling newInputStream() with a path that was never created/mounted in the VFS, a path that was deleted (or whose node was evicted from the VFS cache), or a misspelled/incorrectly-cased path. Also when checkAccess(R_OK) passes but the node lookup fails (e.g. dangling entry after an unmount).","commonSituations":"Opening a file before the remote source is mounted or lazily populated; racing with a delete/removal from another thread; constructing paths with wrong separators or case; stale path cached from a previous mount session.","solutions":["Verify the path exists first via VFS exists()/ls on the parent directory before calling newInputStream","Check for races: ensure no other thread/process deletes the entry between creation and read","Re-check the path string for typos, casing, and the VFS's expected separator","If the source was unmounted/remounted, re-resolve the path against the new mount instead of reusing a stale absolute path"],"exampleFix":"// before\nFileInputStream in = vfs.newInputStream(\"/docs/config.json\");\n// after\nif (vfs.exists(\"/docs/config.json\")) {\n    FileInputStream in = vfs.newInputStream(\"/docs/config.json\");\n} else {\n    // create, mount, or surface a user-facing \"file missing\" state\n}","handlingStrategy":"try-catch","validationCode":"if (vfs == null || !vfs.exists(path)) throw new IllegalStateException(\"VFS path missing: \" + path);","typeGuard":"boolean isReadableFile(VirtualFileSystem vfs, String path) {\n    try {\n        return vfs.checkAccess(path, OsConstants.R_OK);\n    } catch (IOException e) {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    FileInputStream in = vfs.newInputStream(path);\n} catch (FileNotFoundException e) {\n    // path missing in VFS: recreate/mount or inform user\n} catch (IOException e) {\n    // access or type problem\n}","preventionTips":["Always existence-check VFS paths before stream calls","Do not cache VFS paths across unmount/remount cycles","Normalize path separators/casing through one helper","Synchronize file lifecycle (create/delete/read) on a common lock"],"tags":["filesystem","virtual-fs","filenotfound"],"backgroundTag":"file-not-found","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}