{"record":{"id":"8cfe90ba0dd0c927","repo":"MuntashirAkon/AppManager","slug":"invalid-format-invalid-type","errorCode":null,"errorMessage":"Invalid format: Invalid type","messagePattern":"Invalid format: Invalid type","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/rules/struct/RuleEntry.java","lineNumber":84,"sourceCode":"                if (!packageName.equals(newPackageName)) {\n                    throw new IllegalArgumentException(\"Invalid format: package names do not match.\");\n                }\n            } else throw new IllegalArgumentException(\"Invalid format: packageName not found for external rule.\");\n        }\n        if (packageName == null) {\n            // packageName can't be empty\n            throw new IllegalArgumentException(\"Package name cannot be empty.\");\n        }\n        String name;\n        RuleType type;\n        if (tokenizer.hasMoreElements()) {\n            name = tokenizer.nextElement().toString();\n        } else throw new IllegalArgumentException(\"Invalid format: name not found\");\n        if (tokenizer.hasMoreElements()) {\n            try {\n                type = RuleType.valueOf(tokenizer.nextElement().toString());\n            } catch (Exception e) {\n                throw new IllegalArgumentException(\"Invalid format: Invalid type\");\n            }\n        } else throw new IllegalArgumentException(\"Invalid format: entryType not found\");\n        return getRuleEntry(packageName, name, type, tokenizer);\n    }\n\n    @NonNull\n    private static RuleEntry getRuleEntry(@NonNull String packageName, @NonNull String name,\n                                          @NonNull RuleType type, @NonNull StringTokenizer tokenizer)\n            throws IllegalArgumentException {\n        switch (type) {\n            case ACTIVITY:\n            case PROVIDER:\n            case RECEIVER:\n            case SERVICE:\n                return new ComponentRule(packageName, name, type, tokenizer);\n            case APP_OP:\n                return new AppOpRule(packageName, name, tokenizer);\n            case PERMISSION:","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/rules/struct/RuleEntry.java#L66-L102","documentation":"RuleEntry.unflattenFromString parses a tab-separated rule line and converts the third token into a RuleType via RuleType.valueOf. If that token is not a valid RuleType constant name, valueOf throws and the parser rethrows IllegalArgumentException(\"Invalid format: Invalid type\"). This guards against corrupt or hand-edited rule lines whose entry type field is unrecognizable.","triggerScenarios":"Calling RuleEntry.unflattenFromString(packageName, ruleLine, isExternal) with a ruleLine whose third tab-separated token is not an exact RuleType enum name (e.g. 'component' instead of 'COMPONENT', misspelled or renamed type, empty token between two tabs).","commonSituations":"Importing external rules exported by a different App Manager version whose RuleType set differs; hand-editing or truncating a rules.txt; case-sensitivity mistakes since valueOf is case-sensitive; non-tab whitespace separators.","solutions":["Print the offending rule line and fix the third field to an exact uppercase RuleType name (e.g. ACTIVITY, APP_OP).","Re-export the rules from the App Manager version that produced them, or upgrade App Manager so its RuleType covers the type string.","Pre-validate lines with a try/catch around RuleType.valueOf(token) or RuleType.values() lookup before parsing.","Ensure fields are separated by literal tab characters and there are no accidental empty fields."],"exampleFix":"// before\nRuleEntry entry = RuleEntry.unflattenFromString(pkg, line, true);\n// after\nString[] parts = line.split(\"\\t\");\ntry {\n    RuleType.valueOf(parts[parts.length - 1].trim()); // or check known names first\n    RuleEntry entry = RuleEntry.unflattenFromString(pkg, line, true);\n} catch (IllegalArgumentException e) {\n    Log.w(TAG, \"Skipping malformed rule: \" + line);\n}","handlingStrategy":"validation","validationCode":"boolean isValidType(String token) {\n    for (RuleType t : RuleType.values()) {\n        if (t.name().equals(token)) return true;\n    }\n    return false;\n}\n// call only if isValidType(line.split(\"\\t\")[2])","typeGuard":"RuleType safeValueOf(String s) {\n    try { return RuleType.valueOf(s); } catch (IllegalArgumentException e) { return null; }\n}","tryCatchPattern":"try {\n    RuleEntry e = RuleEntry.unflattenFromString(pkg, line, isExternal);\n} catch (IllegalArgumentException e) {\n    Log.w(TAG, \"Skipping malformed rule: \" + line);\n}","preventionTips":["Never hand-edit rules files; only import files produced by the same or newer App Manager version.","Pre-validate the type token against RuleType.values() before parsing.","Use literal tab separators, not spaces."],"tags":["parsing","illegal-argument","rules"],"backgroundTag":"invalid-enum-value","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"}