{"record":{"id":"fd801db0ccf0a2db","repo":"HMCL-dev/HMCL","slug":"entry-not-found-entrypath","errorCode":null,"errorMessage":"Entry not found: {entryPath}","messagePattern":"Entry not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/util/tree/ArchiveFileTree.java","lineNumber":175,"sourceCode":"\n            dir = dir.subDirs.computeIfAbsent(item, Dir::new);\n\n            if (isLastPart) {\n                if (dir.entry == null)\n                    dir.entry = entry;\n                else if (!dir.entry.isDirectory())\n                    LOG.warning(\"A file and a directory have the same name: \" + entry.getName());\n                break;\n            }\n        }\n    }\n\n    public abstract InputStream getInputStream(E entry) throws IOException;\n\n    public @NotNull InputStream getInputStream(String entryPath) throws IOException {\n        E entry = getEntry(entryPath);\n        if (entry == null)\n            throw new FileNotFoundException(\"Entry not found: \" + entryPath);\n        return getInputStream(entry);\n    }\n\n    public BufferedReader getBufferedReader(@NotNull E entry) throws IOException {\n        return new BufferedReader(new InputStreamReader(getInputStream(entry), StandardCharsets.UTF_8));\n    }\n\n    public @NotNull BufferedReader getBufferedReader(String entryPath) throws IOException {\n        E entry = getEntry(entryPath);\n        if (entry == null)\n            throw new FileNotFoundException(\"Entry not found: \" + entryPath);\n        return getBufferedReader(entry);\n    }\n\n    public byte[] readBinaryEntry(@NotNull E entry) throws IOException {\n        try (InputStream input = getInputStream(entry)) {\n            return input.readAllBytes();\n        }","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/util/tree/ArchiveFileTree.java#L157-L193","documentation":"ArchiveFileTree.getInputStream(String entryPath) looks up the entry by path and throws FileNotFoundException 'Entry not found: <entryPath>' when no entry with that path exists in the archive. This is the string-based overload; entry objects bypass the check.","triggerScenarios":"Calling getInputStream(\"path/in/archive\") with a path that does not match any entry — missing entry, wrong casing, missing leading/trailing slash conventions, or path present only in a different archive.","commonSituations":"Reading well-known files like 'fabric.mod.json' or 'plugin.yml' from jars that turn out to be of the other type; files removed/renamed in newer versions of a mod.","solutions":["Check the entry exists first with getEntry(entryPath) != null before opening the stream.","List entries (or use the tree traversal) to find the correct exact path, including case.","Handle the FileNotFoundException and treat the missing file as a soft failure (e.g. mod without plugin.yml).","Verify you opened the intended archive (right jar/version)."],"exampleFix":"// before\nInputStream in = tree.getInputStream(\"fabric.mod.json\"); // FileNotFoundException if absent\n// after\nif (tree.getEntry(\"fabric.mod.json\") != null) {\n    InputStream in = tree.getInputStream(\"fabric.mod.json\");\n} else {\n    // fallback: not a fabric mod\n}","handlingStrategy":"validation","validationCode":"if (tree.getEntry(\"fabric.mod.json\") != null) {\n    try (InputStream in = tree.getInputStream(\"fabric.mod.json\")) { /* ... */ }\n}","typeGuard":null,"tryCatchPattern":"try {\n    InputStream in = tree.getInputStream(entryPath);\n} catch (FileNotFoundException e) {\n    // entry absent; treat as missing file\n}","preventionTips":["Resolve the exact entry path (case included) from the tree before reading.","Guard with getEntry() != null when the file is optional.","Confirm the correct archive version is opened."],"tags":["archive","entry-not-found","io"],"backgroundTag":"file-not-found","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}