{"record":{"id":"7e22e0b9b962877a","repo":"shwenzhang/AndResGuard","slug":"pathnotexist","errorCode":null,"errorMessage":"PathNotExist","messagePattern":"PathNotExist","errorType":"exception","errorClass":"PathNotExist","httpStatus":null,"severity":"error","filePath":"AndResGuard-core/src/main/java/com/tencent/mm/directory/AbstractDirectory.java","lineNumber":98,"sourceCode":"\n  @Override\n  public Map<String, Directory> getDirs() throws UnsupportedOperationException {\n    return getDirs(false);\n  }\n\n  @Override\n  public Map<String, Directory> getDirs(boolean recursive) throws UnsupportedOperationException {\n    return new LinkedHashMap<String, Directory>(getAbstractDirs(recursive));\n  }\n\n  @Override\n  public InputStream getFileInput(String path) throws DirectoryException {\n    SubPath subpath = getSubPath(path);\n    if (subpath.dir != null) {\n      return subpath.dir.getFileInput(subpath.path);\n    }\n    if (!getFiles().contains(subpath.path)) {\n      throw new PathNotExist(path);\n    }\n    return getFileInputLocal(subpath.path);\n  }\n\n  @Override\n  public OutputStream getFileOutput(String path) throws DirectoryException {\n    ParsedPath parsed = parsePath(path);\n    if (parsed.dir == null) {\n      getFiles().add(parsed.subpath);\n      return getFileOutputLocal(parsed.subpath);\n    }\n\n    Directory dir;\n    // IMPOSSIBLE_EXCEPTION\n    try {\n      dir = createDir(parsed.dir);\n    } catch (PathAlreadyExists e) {\n      dir = getAbstractDirs().get(parsed.dir);","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/shwenzhang/AndResGuard/blob/e4df245d82f27d9a2d0dd108260a3510cbaba849/AndResGuard-core/src/main/java/com/tencent/mm/directory/AbstractDirectory.java#L80-L116","documentation":"AbstractDirectory.getFileInput(path) resolves the path against the directory's sub-paths and file list. If the path does not resolve to a subdirectory and is not present in the files set, it throws PathNotExist (a DirectoryException) rather than returning null, signaling the caller asked for input from a file that isn't in this directory.","triggerScenarios":"Calling getFileInput(\"some/path\") on an AbstractDirectory (e.g. a decoded APK directory) where the path is neither a registered subdirectory entry nor contained in getFiles() — the file was never extracted, was deleted, or the path is misnamed/wrongly cased.","commonSituations":"AndResGuard pipeline steps requesting files like resources.arsc or AndroidManifest.xml from a directory that was decoded incorrectly, cleaned by a previous step, or where the filename case doesn't match (Linux is case-sensitive); running steps out of order after a failed decode.","solutions":["Verify the file actually exists at the expected path (ls the working directory) and check exact case-sensitive spelling.","Ensure the decode/unpack step completed successfully before steps that call getFileInput.","Confirm the path passed is relative to the directory root without leading slashes or '..'.","Catch DirectoryException and re-create/decode the directory if the file is legitimately absent."],"exampleFix":"// before\nInputStream in = dir.getFileInput(\"Resources.arsc\");\n// after\nString name = \"resources.arsc\"; // exact case as stored\nif (!dir.getFiles().contains(name)) {\n  throw new IllegalStateException(\"missing \" + name);\n}\nInputStream in = dir.getFileInput(name);","handlingStrategy":"try-catch","validationCode":"// Check membership before requesting input\nString resolved = \"resources.arsc\";\nif (!dir.getFiles().contains(resolved)) {\n  throw new IllegalStateException(\"file not present in decoded dir: \" + resolved);\n}\nInputStream in = dir.getFileInput(resolved);","typeGuard":null,"tryCatchPattern":"try {\n  InputStream in = dir.getFileInput(path);\n} catch (DirectoryException e) {\n  if (e.getMessage().contains(\"PathNotExist\")) {\n    // re-decode the APK or recreate the directory, then retry\n  } else throw e;\n}","preventionTips":["Always confirm decode/unzip completed before reading files via getFileInput.","Use exact, case-sensitive relative paths (no leading '/', no '..').","On Linux CI, verify filename casing matches what aapt produced.","List dir.getFiles() in debug logs to catch path mismatches early."],"tags":["file-not-found","android","directory","path"],"backgroundTag":"file-not-found","analyzedSha":"e4df245d82f27d9a2d0dd108260a3510cbaba849","analyzedAt":"2026-09-12T17:49:07.798Z","contentChangedAt":"2026-09-12T17:49:07.798Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}