{"record":{"id":"dedbe618ae37c9dd","repo":"MuntashirAkon/AppManager","slug":"invalid-key-key-lastupdateoption","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/LastUpdateOption.java","lineNumber":46,"sourceCode":"    @NonNull\n    @Override\n    public Map<String, Integer> getKeysWithType() {\n        return mKeysWithType;\n    }\n\n    @NonNull\n    @Override\n    public TestResult test(@NonNull IFilterableAppInfo info, @NonNull TestResult result) {\n        boolean installed = info.isInstalled();\n        switch (key) {\n            case KEY_ALL:\n                return result.setMatched(true);\n            case \"before\":\n                return result.setMatched(installed && info.getLastUpdateTime() <= longValue);\n            case \"after\":\n                return result.setMatched(installed && info.getLastUpdateTime() >= longValue);\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(\"Last update\");\n        switch (key) {\n            case KEY_ALL:\n                return sb.append(LangUtils.getSeparatorString()).append(\"any\");\n            case \"before\":\n                return sb.append(\" before \").append(DateUtils.formatDateTime(context, longValue));\n            case \"after\":\n                return sb.append(\" after \").append(DateUtils.formatDateTime(context, longValue));\n            default:\n                throw new UnsupportedOperationException(\"Invalid key \" + key);\n        }\n    }","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/filters/options/LastUpdateOption.java#L28-L64","documentation":"LastUpdateOption.test() switches over the configured key (all/before/after); any other key hits the default branch and throws UnsupportedOperationException. Since setKeyValue() validates keys against the key map, this error means the key state and the test() switch are out of sync.","triggerScenarios":"A key in LastUpdateOption's key map without a case in test()'s switch; the protected `key` field mutated directly; stale keys from hand-built Parcels or reflection.","commonSituations":"Adding a new time-comparison key without updating test(); forked builds with extra keys; deserialization of crafted filter data.","solutions":["Add a case for the key in LastUpdateOption.test()'s switch.","Set keys only via setKeyValue() for validation.","Keep the key map and test() switch synchronized."],"exampleFix":"// before\ncase \"after\":\n    return result.setMatched(installed && info.getLastUpdateTime() >= longValue);\ndefault:\n    throw new UnsupportedOperationException(\"Invalid key \" + key);\n// after\ncase \"after\":\n    return result.setMatched(installed && info.getLastUpdateTime() >= longValue);\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":["Keep LastUpdateOption's key map and test() switch in sync.","Assign keys only via setKeyValue().","Unit-test test() and toLocalizedString() for all keys."],"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"}