{"record":{"id":"408cf37c8a7a94f4","repo":"MuntashirAkon/AppManager","slug":"invalid-format-name-not-found","errorCode":null,"errorMessage":"Invalid format: name not found","messagePattern":"Invalid format: name not found","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/rules/struct/RuleEntry.java","lineNumber":79,"sourceCode":"            // External rules, the first part is the package name\n            if (tokenizer.hasMoreElements()) {\n                // Match package name\n                String newPackageName = tokenizer.nextElement().toString();\n                if (packageName == null) packageName = newPackageName;\n                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:","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/rules/struct/RuleEntry.java#L61-L97","documentation":"RuleEntry.unflattenFromString reads the entry name (the stub or component/permission name) as the token after the package name. If the tokenizer is exhausted at that point it throws this IllegalArgumentException, since every rule entry requires a name field before the rule type.","triggerScenarios":"Calling unflattenFromString with a string containing only the package name (single token), leaving no token for the name field.","commonSituations":"Truncated lines in imported rules files, hand-written strings that omit the name token, or parsing tokens consumed prematurely by custom code.","solutions":["Include the name token (use the STUB value for package-level rules) after the package name","Verify the flattened string has at least 3 tokens: packageName, name, type","Re-export the rules file to restore the full format","Catch IllegalArgumentException and skip malformed entries during import"],"exampleFix":"// before\nRuleEntry.unflattenFromString(\"com.example\", null); // throws: name missing\n// after\nRuleEntry.unflattenFromString(\"com.example\\t__stub__\\tPERMISSION\\tandroid.permission.CAMERA\\ttrue\\t0\", null);","handlingStrategy":"try-catch","validationCode":"String[] p = line.split(\"\\t\");\nif (p.length < 3) throw new IllegalArgumentException(\"rule needs packageName, name, and type\");","typeGuard":"boolean hasMinimumTokens(String line) { return line.split(\"\\t\").length >= 3; }","tryCatchPattern":"try { RuleEntry.unflattenFromString(line, null); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"name not found\")) skipTruncated(line); }","preventionTips":["Use the STUB token for package-level rules so the name field is always present","Require at least 3 tokens (package, name, type) before parsing","Treat import lines shorter than the schema as corrupt and report them"],"tags":["rules-parsing","illegal-argument"],"backgroundTag":"invalid-argument-format","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}