MuntashirAkon/AppManager · error · UnsupportedOperationException

Invalid key ${key}

Error message

Invalid key ${key}

What it means

PermissionsOption.test filters requested permissions by switching on the key (e.g. permission-name matching modes). An unrecognized key falls into default and throws UnsupportedOperationException 'Invalid key <key>'. The option received a key it has no matching logic for.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/filters/options/PermissionsOption.java:104

                        filteredPermissions.add(permission);
                    }
                }
                return result.setMatched(!filteredPermissions.isEmpty())
                        .setMatchedPermissions(filteredPermissions);
            }
            case "regex": {
                Objects.requireNonNull(value);
                List<String> filteredPermissions = new ArrayList<>();
                for (String permission : permissions) {
                    if (regexValue.matcher(permission).matches()) {
                        filteredPermissions.add(permission);
                    }
                }
                return result.setMatched(!filteredPermissions.isEmpty())
                        .setMatchedPermissions(filteredPermissions);
            }
            default:
                throw new UnsupportedOperationException("Invalid key " + key);
        }
    }

    @NonNull
    @Override
    public CharSequence toLocalizedString(@NonNull Context context) {
        SpannableStringBuilder sb = new SpannableStringBuilder("Permissions");
        switch (key) {
            case KEY_ALL:
                return sb.append(LangUtils.getSeparatorString()).append("any");
            case "eq":
                return sb.append(" = '").append(value).append("'");
            case "contains":
                return sb.append(" contains '").append(value).append("'");
            case "starts_with":
                return sb.append(" starts with '").append(value).append("'");
            case "ends_with":
                return sb.append(" ends with '").append(value).append("'");

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Set the key to a value supported by PermissionsOption.
  2. Re-create the filter in the UI.
  3. Validate keys during filter deserialization.
  4. Add the missing case to the switch if a new mode is required.

Example fix

// before
new PermissionsOption("permissions", "contain", "android.permission.CAMERA");
// after
new PermissionsOption("permissions", "starts_with", "android.permission.CAMERA");
Defensive patterns

Strategy: validation

Validate before calling

if (!SUPPORTED_KEYS.contains(option.getKey())) throw new IllegalArgumentException("Unsupported permissions key: " + option.getKey());

Type guard

boolean isValidKey(String k) { return k != null && SUPPORTED_KEYS.contains(k); } // SUPPORTED_KEYS mirrors the switch cases

Try / catch

try { matched = option.test(info); } catch (UnsupportedOperationException e) { matched = false; Log.w(TAG, "Bad filter key", e); }

Prevention

When it happens

Trigger: Calling test() on a PermissionsOption whose key is not among the supported permission-filter keys — from a mistyped filter file entry, a key renamed between versions, or a key copied from another option type.

Common situations: Shared/edited filter JSON with wrong key; filters created by a different App Manager version; scripted filter generation using raw unvalidated strings.

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/e07ffabccb552847. Report an issue: GitHub.