{"record":{"id":"093234aed97701d9","repo":"MuntashirAkon/AppManager","slug":"invalid-key-key-packagenameoption","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/PackageNameOption.java","lineNumber":70,"sourceCode":"                }\n                return result.setMatched(false);\n            case \"eq_none\":\n                for (String packageName: stringValues) {\n                    if (info.getPackageName().equals(packageName)) {\n                        return result.setMatched(false);\n                    }\n                }\n                return result.setMatched(true);\n            case \"contains\":\n                return result.setMatched(info.getPackageName().contains(Objects.requireNonNull(value)));\n            case \"starts_with\":\n                return result.setMatched(info.getPackageName().startsWith(Objects.requireNonNull(value)));\n            case \"ends_with\":\n                return result.setMatched(info.getPackageName().endsWith(Objects.requireNonNull(value)));\n            case \"regex\":\n                return result.setMatched(regexValue.matcher(info.getPackageName()).matches());\n            default:\n                throw new UnsupportedOperationException(\"Invalid key \" + key);\n        }\n    }\n\n    @NonNull\n    @Override\n    public CharSequence toLocalizedString(@NonNull Context context) {\n        SpannableStringBuilder sb = new SpannableStringBuilder(\"Package name\");\n        switch (key) {\n            case KEY_ALL:\n                return sb.append(LangUtils.getSeparatorString()).append(\"any\");\n            case \"eq\":\n                return sb.append(\" = '\").append(value).append(\"'\");\n            case \"eq_any\":\n                return sb.append(\" matching any of \").append(String.join(\", \", stringValues));\n            case \"eq_none\":\n                return sb.append(\" matching none of \").append(String.join(\", \", stringValues));\n            case \"contains\":\n                return sb.append(\" contains '\").append(value).append(\"'\");","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/filters/options/PackageNameOption.java#L52-L88","documentation":"PackageNameOption.test matches the package name using key-driven logic ('starts_with', 'ends_with', 'regex', etc.). An unrecognized key reaches default and throws UnsupportedOperationException 'Invalid key <key>'. The filter's match-type key is not valid for package-name matching.","triggerScenarios":"Calling test() on a PackageNameOption whose key is not one of the supported match types — e.g. 'contains' misspelled, 'startswith' without underscore, or a key from a different option type.","commonSituations":"Hand-edited or shared filter JSON with near-miss key names; filters authored against a different app version; copy-paste of keys between filter options with different vocabularies.","solutions":["Fix the key to a supported value ('starts_with', 'ends_with', 'regex', etc. as defined by the option).","Re-create the filter in the app UI.","Validate the match-type key when parsing the filter file.","If 'contains' or another match type is genuinely needed, add that case to the switch."],"exampleFix":"// before\nnew PackageNameOption(\"package_name\", \"startswith\", \"com.example\");\n// after\nnew PackageNameOption(\"package_name\", \"starts_with\", \"com.example\");","handlingStrategy":"validation","validationCode":"Set<String> VALID = Set.of(\"starts_with\", \"ends_with\", \"regex\");\nif (!VALID.contains(option.getKey())) throw new IllegalArgumentException(\"Unsupported package_name key: \" + option.getKey());","typeGuard":"boolean isValidKey(String k) { return \"starts_with\".equals(k) || \"ends_with\".equals(k) || \"regex\".equals(k); }","tryCatchPattern":"try { matched = option.test(info); } catch (UnsupportedOperationException e) { matched = false; }","preventionTips":["Use exact snake_case keys as in the switch","Validate match-type keys on import","Don't invent keys not present in the source","Check the option class docs for the key set"],"tags":["android","filter-options","unsupported-key","package-name"],"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-14T16:17:12.679Z"}