{"record":{"id":"31539d68c3dbcec8","repo":"MuntashirAkon/AppManager","slug":"invalid-key-key-freezeoption","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/FreezeOption.java","lineNumber":72,"sourceCode":"    }\n\n    @NonNull\n    @Override\n    public TestResult test(@NonNull IFilterableAppInfo info, @NonNull TestResult result) {\n        int freezeFlags = info.getFreezeFlags();\n        switch (key) {\n            case KEY_ALL:\n                return result.setMatched(true);\n            case \"frozen\":\n                return result.setMatched(freezeFlags != 0);\n            case \"unfrozen\":\n                return result.setMatched(freezeFlags == 0);\n            case \"with_flags\":\n                return result.setMatched((freezeFlags & intValue) == intValue);\n            case \"without_flags\":\n                return result.setMatched((freezeFlags & intValue) != intValue);\n            default:\n                throw new UnsupportedOperationException(\"Invalid key \" + key);\n        }\n    }\n\n    @NonNull\n    @Override\n    public CharSequence toLocalizedString(@NonNull Context context) {\n        switch (key) {\n            case KEY_ALL:\n                return \"Frozen\" + getSeparatorString() + \" any\";\n            case \"frozen\":\n                return \"Frozen apps only\";\n            case \"unfrozen\":\n                return \"Unfrozen apps only\";\n            case \"with_flags\":\n                return \"Frozen apps with types \" + flagsToString(\"with_flags\", intValue);\n            case \"without_flags\":\n                return \"Frozen apps without types \" + flagsToString(\"without_flags\", intValue);\n            default:","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/filters/options/FreezeOption.java#L54-L90","documentation":"FreezeOption.test() switches over the option's configured key (all/frozen/unfrozen/with_flags/without_flags); any other key hits the default branch and throws UnsupportedOperationException. In normal use setKeyValue() already rejects unknown keys, so this indicates the internal key state was set outside the validated path or the switch lags the key map.","triggerScenarios":"A key added to FreezeOption's mKeysWithType map but not handled in test()'s switch; the protected `key` field mutated directly bypassing setKeyValue(); constructing an option via reflection/serialization with a stale key.","commonSituations":"Developer adds a new freeze filter key but forgets the test() case; a fork or modified build with extra keys; deserialization of a hand-crafted Parcel.","solutions":["Add a case for the new key in FreezeOption.test()'s switch.","Ensure the key is only set via setKeyValue() so it is validated against mKeysWithType.","Keep mKeysWithType and the test()/toLocalizedString() switches in sync."],"exampleFix":"// before\ncase \"without_flags\":\n    return result.setMatched((freezeFlags & intValue) != intValue);\ndefault:\n    throw new UnsupportedOperationException(\"Invalid key \" + key);\n// after\ncase \"without_flags\":\n    return result.setMatched((freezeFlags & intValue) != intValue);\ncase \"new_key\":\n    return result.setMatched(/* logic */);\ndefault:\n    throw new UnsupportedOperationException(\"Invalid key \" + key);","handlingStrategy":"validation","validationCode":"if (!option.getKeysWithType().containsKey(option.getKey())) {\n    throw new IllegalStateException(\"Unrecognized key: \" + option.getKey());\n}","typeGuard":null,"tryCatchPattern":"try {\n    result = option.test(info, result);\n} catch (UnsupportedOperationException e) {\n    Log.w(TAG, \"Filter option key not supported\", e);\n    result.setMatched(false);\n}","preventionTips":["Only assign keys via setKeyValue(); never write the protected key field directly.","Add a test() case for every entry in the option's key map.","Unit-test toLocalizedString() and test() over all keys of each option."],"tags":["java","android","switch-statement","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}