{"record":{"id":"c5270bc2393cbab8","repo":"MuntashirAkon/AppManager","slug":"invalid-key-key-signatureoption","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/SignatureOption.java","lineNumber":137,"sourceCode":"                    if (regexValue.matcher(subject).matches()) {\n                        matchedSubjectLines.add(subject);\n                    }\n                }\n                return result.setMatched(!matchedSubjectLines.isEmpty())\n                        .setMatchedSubjectLines(matchedSubjectLines);\n            }\n            case \"sha256\": {\n                String[] sha256sums = info.getSignatureSha256Checksums();\n                for (int i = 0; i < sha256sums.length; ++i) {\n                    if (sha256sums[i].equals(value)) {\n                        return result.setMatched(true)\n                                .setMatchedSubjectLines(Collections.singletonList(info.getSignatureSubjectLines()[i]));\n                    }\n                }\n                return result.setMatched(false).setMatchedSubjectLines(Collections.emptyList());\n            }\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(\"Signatures\");\n        switch (key) {\n            case KEY_ALL:\n                return sb.append(LangUtils.getSeparatorString()).append(\"any\");\n            case \"no_signer\":\n                return sb.append(LangUtils.getSeparatorString()).append(\"none\");\n            case \"with_lineage\":\n                return sb.append(\" with lineages\");\n            case \"without_lineage\":\n                return sb.append(\" without lineages\");\n            case \"with_source_stamp\":\n                return sb.append(\" with source stamps\");","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/filters/options/SignatureOption.java#L119-L155","documentation":"SignatureOption.test() evaluates whether a package's signing info matches a filter criterion by switching on the option's key (subject starts-with, ends-with, regex, sha256, etc.). If the key is unrecognized it throws UnsupportedOperationException('Invalid key ...'), since test() cannot decide a match for an unknown criterion.","triggerScenarios":"Invoking test() on a SignatureOption whose key is not among the implemented case labels — typically from a stale or hand-crafted filter definition.","commonSituations":"Applying old saved filters after an upgrade that renamed keys; sharing filter rules between versions; typos in programmatically generated filters.","solutions":["Inspect the failing option's key and correct it to a supported key used in SignatureOption.test()","Migrate/regenerate the persisted filter to the current key vocabulary","Extend test() (and toLocalizedString) with the missing key if you intentionally added a new criterion"],"exampleFix":"// before\nSignatureOption opt = new SignatureOption(\"subj_sw\", value);\n// after\nSignatureOption opt = new SignatureOption(\"subject_starts_with\", value); // supported key","handlingStrategy":"validation","validationCode":"Set<String> validKeys = Set.of(\"subject_starts_with\",\"subject_ends_with\",\"sub_regex\",\"sha256\");\nif (!validKeys.contains(opt.getKey())) throw new IllegalArgumentException(\"Bad signature filter key: \" + opt.getKey());","typeGuard":null,"tryCatchPattern":"try {\n    matched = option.test(packageInfo);\n} catch (UnsupportedOperationException e) {\n    matched = false;\n    Log.w(TAG, \"Skipping filter with unknown key\", e);\n}","preventionTips":["Define key constants in one place shared by test() and toLocalizedString()","Migrate persisted filters when key names change","Test round-trip serialization of every filter type"],"tags":["java","android","filters"],"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"}