{"record":{"id":"964e681f7eb7436d","repo":"Tencent/matrix","slug":"apk-unzip-path-inputpath-is-not-directory-964e68","errorCode":null,"errorMessage":"---APK-UNZIP-PATH '<inputPath>' is not directory!","messagePattern":"---APK-UNZIP-PATH '<inputPath>' is not directory!","errorType":"validation","errorClass":"TaskInitException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/FindNonAlphaPngTask.java","lineNumber":77,"sourceCode":"    private Map<String, String> entryNameMap;\n\n    public FindNonAlphaPngTask(JobConfig config, Map<String, String> params) {\n        super(config, params);\n        type = TASK_TYPE_FIND_NON_ALPHA_PNG;\n    }\n\n    @Override\n    public void init() throws TaskInitException {\n        super.init();\n        String inputPath = config.getUnzipPath();\n        if (Util.isNullOrNil(inputPath)) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH can not be null!\");\n        }\n        inputFile = new File(inputPath);\n        if (!inputFile.exists()) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH '\" + inputPath + \"'is not exists!\");\n        } else if (!inputFile.isDirectory()) {\n            throw new TaskInitException(TAG + \"---APK-UNZIP-PATH '\" + inputPath + \"' is not directory!\");\n        }\n        if (params.containsKey(JobConstants.PARAM_MIN_SIZE_IN_KB)) {\n            try {\n                downLimitSize = Long.parseLong(params.get(JobConstants.PARAM_MIN_SIZE_IN_KB));\n            } catch (NumberFormatException e) {\n                Log.e(TAG, \"DOWN-LIMIT-SIZE '\" + params.get(JobConstants.PARAM_MIN_SIZE_IN_KB) + \"' is not number format!\");\n            }\n        }\n        nonAlphaPngList = new ArrayList<Pair<String, Long>>();\n        entrySizeMap = config.getEntrySizeMap();\n        entryNameMap = config.getEntryNameMap();\n    }\n\n    private void findNonAlphaPng(File file) throws IOException {\n        if (file != null) {\n            if (file.isDirectory()) {\n                File[] files = file.listFiles();\n                for (File tempFile : files) {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/FindNonAlphaPngTask.java#L59-L95","documentation":"FindNonAlphaPngTask.init() throws TaskInitException when the unzip path exists but is a regular file rather than a directory. The task iterates files under the directory (res/, assets/) looking for PNGs, so a file path breaks traversal assumptions.","triggerScenarios":"config.getUnzipPath() points to an existing file (e.g. the APK itself or a single file) instead of the unzipped APK root directory.","commonSituations":"Passing the .apk path to --unzip instead of --apk; pointing at a lone extracted file; misconfigured CI variables mixing artifact and extraction paths.","solutions":["Point --unzip at the directory containing the extracted APK contents (with res/, AndroidManifest.xml).","Run UnzipTask/unzip first and pass its output directory.","Validate with `test -d <path>` in your build script before invoking the checker."],"exampleFix":"// before\nconfig.setUnzipPath(apkFilePath); // wrong: file, not dir\n// after\nconfig.setUnzipPath(extractedDir.getAbsolutePath()); // output of unzip step","handlingStrategy":"validation","validationCode":"File dir = new File(config.getUnzipPath());\nif (dir.exists() && !dir.isDirectory()) {\n    throw new IllegalStateException(\"unzip path is a file, expected directory: \" + dir);\n}","typeGuard":null,"tryCatchPattern":"try {\n    task.init();\n} catch (TaskInitException e) {\n    if (e.getMessage().contains(\"is not directory\")) {\n        config.setUnzipPath(extractedDir.getAbsolutePath());\n    }\n}","preventionTips":["Distinguish --apk (file) from --unzip (directory) arguments clearly in scripts.","Check with `test -f` vs `test -d` in CI before running.","Regenerate the extraction directory if it was replaced by a file."],"tags":["android","apk-checker","filesystem"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}