{"record":{"id":"d2b9b07050e169a9","repo":"MuntashirAkon/AppManager","slug":"invalid-key-key-bloatwareoption","errorCode":null,"errorMessage":"Invalid key ${key}","messagePattern":"Invalid key (.+?)","errorType":"validation","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/filters/options/BloatwareOption.java","lineNumber":85,"sourceCode":"    }\n\n    @NonNull\n    @Override\n    public TestResult test(@NonNull IFilterableAppInfo info, @NonNull TestResult result) {\n        DebloatObject object = info.getBloatwareInfo();\n        if (object == null) {\n            return result.setMatched(false);\n        }\n        // Must be a bloatware\n        switch (key) {\n            case KEY_ALL:\n                return result.setMatched(true);\n            case \"type\":\n                return result.setMatched((typeToFlag(object.type) & intValue) != 0);\n            case \"removal\":\n                return result.setMatched((object.getRemoval() & intValue) != 0);\n            default:\n                throw new UnsupportedOperationException(\"Invalid key \" + key);\n        }\n    }\n\n    public int typeToFlag(@NonNull String type) {\n        switch (type) {\n            case \"aosp\":\n                return FILTER_LIST_AOSP;\n            case \"carrier\":\n                return FILTER_LIST_CARRIER;\n            case \"google\":\n                return FILTER_LIST_GOOGLE;\n            case \"misc\":\n                return FILTER_LIST_MISC;\n            case \"oem\":\n                return FILTER_LIST_OEM;\n            default:\n                throw new IllegalArgumentException(\"Unknown type: \" + type);\n        }","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/filters/options/BloatwareOption.java#L67-L103","documentation":"BloatwareOption.test() evaluates an app against the bloatware list using its key (\"list\" and \"any\", \"type\", \"removal\"); an unrecognized key reaches the default branch and throws UnsupportedOperationException(\"Invalid key \" + key). It indicates the option was constructed with a key this class cannot evaluate.","triggerScenarios":"Creating BloatwareOption with a key not in its switch (e.g. \"app_type\" or a misspelled \"lst\") and running app-list filtering; stale saved filters from older versions; copy-pasted option construction from another filter class.","commonSituations":"Renaming keys across filter classes without updating call sites; programmatic filter builders using wrong key constants; restoring exported filter configs from incompatible versions.","solutions":["Construct BloatwareOption only with supported keys: \"list\", \"type\", or \"removal\"","Add the missing case to test() if a new key is intended","Correct any copy-pasted key strings from other option classes","Validate persisted filter keys against the current schema before applying them"],"exampleFix":"// before\nFilterOption opt = new BloatwareOption(\"bloat\", \"types\"); // typo\nboolean m = opt.test(packageInfo).isMatched(); // throws\n// after\nFilterOption opt = new BloatwareOption(\"bloat\", \"type\"); // supported key\nboolean m = opt.test(packageInfo).isMatched();","handlingStrategy":"type-guard","validationCode":"Set<String> VALID = Set.of(\"list\",\"any\",\"type\",\"removal\"); if (!VALID.contains(key)) throw new IllegalArgumentException(\"Unsupported BloatwareOption key: \" + key);","typeGuard":"boolean isValidBloatKey(String key) { return key != null && Set.of(\"list\",\"any\",\"type\",\"removal\").contains(key); }","tryCatchPattern":"try { boolean matched = option.test(packageInfo).isMatched(); } catch (UnsupportedOperationException e) { matched = false; /* ignore malformed bloat filter entry */ }","preventionTips":["Centralize bloatware filter key constants","Migrate saved filters between app versions","Don't copy key strings from other FilterOption classes","Validate filter configs on import/export"],"tags":["android","filters","bloatware","unsupported-key"],"backgroundTag":"unsupported-operation","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"}