{"record":{"id":"57f45f7c5035826c","repo":"MuntashirAkon/AppManager","slug":"invalid-format-mode-not-found","errorCode":null,"errorMessage":"Invalid format: mode not found","messagePattern":"Invalid format: mode not found","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/rules/struct/AppOpRule.java","lineNumber":30,"sourceCode":"\npublic class AppOpRule extends RuleEntry {\n    private final int mOp;\n    @AppOpsManagerCompat.Mode\n    private int mMode;\n\n    public AppOpRule(@NonNull String packageName, int op, @AppOpsManagerCompat.Mode int mode) {\n        super(packageName, String.valueOf(op), RuleType.APP_OP);\n        mOp = op;\n        mMode = mode;\n    }\n\n    public AppOpRule(@NonNull String packageName, String opInt, @NonNull StringTokenizer tokenizer)\n            throws RuntimeException {\n        super(packageName, opInt, RuleType.APP_OP);\n        mOp = Integer.parseInt(opInt);\n        if (tokenizer.hasMoreElements()) {\n            mMode = Integer.parseInt(tokenizer.nextElement().toString());\n        } else throw new IllegalArgumentException(\"Invalid format: mode not found\");\n    }\n\n    public int getOp() {\n        return mOp;\n    }\n\n    @AppOpsManagerCompat.Mode\n    public int getMode() {\n        return mMode;\n    }\n\n    public void setMode(@AppOpsManagerCompat.Mode int mode) {\n        mMode = mode;\n    }\n\n    @NonNull\n    @Override\n    public String toString() {","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/rules/struct/AppOpRule.java#L12-L48","documentation":"AppOpRule parses a TSV rule line: the op code comes from opInt, and the mode must be the next token in the StringTokenizer. If the token stream is exhausted, the rule line is malformed and the constructor throws IllegalArgumentException('Invalid format: mode not found').","triggerScenarios":"Constructing AppOpRule with a tokenizer that has no remaining element — i.e. an app-op rule line containing only the package and op code without a mode field.","commonSituations":"Hand-edited or truncated rules backup TSV files; importing rules exported by an older App Manager version with a different line format; copy-paste dropping the last column.","solutions":["Fix the rule source so each APP_OP line has: package, op code, and mode (e.g. pkg<TAB>op<TAB>mode)","Validate token count before constructing, or catch IllegalArgumentException per line and skip malformed rows","Re-export the rules from a current App Manager version to regenerate well-formed lines"],"exampleFix":"// before\nAppOpRule rule = new AppOpRule(pkg, opInt, new StringTokenizer(line, \"\\t\"));\n// after\nStringTokenizer st = new StringTokenizer(line, \"\\t\");\nif (st.countTokens() < 2) {\n    Log.w(TAG, \"Skipping malformed app-op line: \" + line);\n    return;\n}\nAppOpRule rule = new AppOpRule(pkg, opInt, st);","handlingStrategy":"validation","validationCode":"StringTokenizer st = new StringTokenizer(line, \"\\t\");\nif (st.countTokens() < 3) { // package + op + mode\n    Log.w(TAG, \"Malformed APP_OP line: \" + line);\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    rule = new AppOpRule(pkg, opInt, tokenizer);\n} catch (IllegalArgumentException e) {\n    Log.w(TAG, \"Skipping invalid app-op rule: \" + line, e);\n}","preventionTips":["Validate column count per TSV line before constructing rules","Keep rule files generated by the same app version that will import them","Never hand-edit exported TSV backups; re-export instead"],"tags":["parsing","tsv","rules","format"],"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-14T16:17:12.679Z"}