{"record":{"id":"56889907a5ab4860","repo":"MuntashirAkon/AppManager","slug":"invalid-key-key-screentimeoption","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/ScreenTimeOption.java","lineNumber":48,"sourceCode":"    @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        switch (key) {\n            case KEY_ALL:\n                return result.setMatched(true);\n            case \"eq\":\n                return result.setMatched(info.getTotalScreenTime() == longValue);\n            case \"le\":\n                return result.setMatched(info.getTotalScreenTime() <= longValue);\n            case \"ge\":\n                return result.setMatched(info.getTotalScreenTime() >= 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(\"Screentime\");\n        switch (key) {\n            case KEY_ALL:\n                return sb.append(LangUtils.getSeparatorString()).append(\"any\");\n            case \"eq\":\n                return sb.append(\" = \").append(DateUtils.getFormattedDuration(context, longValue, false, true));\n            case \"le\":\n                return sb.append(\" ≤ \").append(DateUtils.getFormattedDuration(context, longValue, false, true));\n            case \"ge\":\n                return sb.append(\" ≥ \").append(DateUtils.getFormattedDuration(context, longValue, false, true));\n            default:\n                throw new UnsupportedOperationException(\"Invalid key \" + key);","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/filters/options/ScreenTimeOption.java#L30-L66","documentation":"ScreenTimeOption.test compares total screen time by switching on key ('eq', 'le', 'ge'). An unrecognized key reaches default and throws UnsupportedOperationException 'Invalid key <key>'. The filter's comparison key is not a valid screen-time operator.","triggerScenarios":"Calling test() on a ScreenTimeOption whose key is not 'eq', 'le', or 'ge' — from a typo in a filter file, keys copied from other options (e.g. 'before'), or version drift.","commonSituations":"Hand-edited filter JSON; shared filters across app versions; programmatic filter construction without key validation.","solutions":["Change the key to 'eq', 'le', or 'ge'.","Re-create the filter in the UI.","Validate keys at deserialization time.","Add the missing case if a new comparison is intended."],"exampleFix":"// before\nnew ScreenTimeOption(\"screen_time\", \"<\", 3600000L);\n// after\nnew ScreenTimeOption(\"screen_time\", \"le\", 3600000L);","handlingStrategy":"validation","validationCode":"Set<String> VALID = Set.of(\"eq\", \"le\", \"ge\");\nif (!VALID.contains(option.getKey())) throw new IllegalArgumentException(\"Unsupported screen_time key: \" + option.getKey());","typeGuard":"boolean isValidKey(String k) { return \"eq\".equals(k) || \"le\".equals(k) || \"ge\".equals(k); }","tryCatchPattern":"try { matched = option.test(info); } catch (UnsupportedOperationException e) { matched = false; }","preventionTips":["Use canonical eq/le/ge keys","Validate keys on filter import","Avoid borrowing keys from time-based options","Add coverage for the default branch"],"tags":["android","filter-options","unsupported-key","screen-time"],"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"}