MuntashirAkon/AppManager · error · UnsupportedOperationException
Invalid key ${key}
Error message
Invalid key ${key} What it means
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.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/filters/options/ScreenTimeOption.java:48
@Override
public Map<String, Integer> getKeysWithType() {
return mKeysWithType;
}
@NonNull
@Override
public TestResult test(@NonNull IFilterableAppInfo info, @NonNull TestResult result) {
switch (key) {
case KEY_ALL:
return result.setMatched(true);
case "eq":
return result.setMatched(info.getTotalScreenTime() == longValue);
case "le":
return result.setMatched(info.getTotalScreenTime() <= longValue);
case "ge":
return result.setMatched(info.getTotalScreenTime() >= longValue);
default:
throw new UnsupportedOperationException("Invalid key " + key);
}
}
@NonNull
@Override
public CharSequence toLocalizedString(@NonNull Context context) {
SpannableStringBuilder sb = new SpannableStringBuilder("Screentime");
switch (key) {
case KEY_ALL:
return sb.append(LangUtils.getSeparatorString()).append("any");
case "eq":
return sb.append(" = ").append(DateUtils.getFormattedDuration(context, longValue, false, true));
case "le":
return sb.append(" ≤ ").append(DateUtils.getFormattedDuration(context, longValue, false, true));
case "ge":
return sb.append(" ≥ ").append(DateUtils.getFormattedDuration(context, longValue, false, true));
default:
throw new UnsupportedOperationException("Invalid key " + key);View on GitHub (pinned to 0152f468fc)
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.
Example fix
// before
new ScreenTimeOption("screen_time", "<", 3600000L);
// after
new ScreenTimeOption("screen_time", "le", 3600000L); Defensive patterns
Strategy: validation
Validate before calling
Set<String> VALID = Set.of("eq", "le", "ge");
if (!VALID.contains(option.getKey())) throw new IllegalArgumentException("Unsupported screen_time key: " + option.getKey()); Type guard
boolean isValidKey(String k) { return "eq".equals(k) || "le".equals(k) || "ge".equals(k); } Try / catch
try { matched = option.test(info); } catch (UnsupportedOperationException e) { matched = false; } Prevention
- Use canonical eq/le/ge keys
- Validate keys on filter import
- Avoid borrowing keys from time-based options
- Add coverage for the default branch
When it happens
Trigger: 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.
Common situations: Hand-edited filter JSON; shared filters across app versions; programmatic filter construction without key validation.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/56889907a5ab4860.
Report an issue: GitHub.