MuntashirAkon/AppManager · error · UnsupportedOperationException

Invalid key

Error message

Invalid key ${key}

What it means

InstallerOption.test() switches over the configured key (installer_all/installer_any/installer_none/regex/etc.); an unhandled key reaches the default branch and throws UnsupportedOperationException. Keys are normally validated by setKeyValue(), so this indicates the switch does not cover the option's configured key.

Solutions

  1. Add a case for the key in InstallerOption.test()'s switch.
  2. Assign keys only via setKeyValue().
  3. Keep InstallerOption's key map and test() switch in sync.

Example fix

// before
default:
    throw new UnsupportedOperationException("Invalid key " + key);
// after
case "new_installer_key":
    return result.setMatched(/* logic */);
default:
    throw new UnsupportedOperationException("Invalid key " + key);
Defensive patterns

Strategy: validation

Validate before calling

if (!option.getKeysWithType().containsKey(option.getKey())) {
    throw new IllegalStateException("Unrecognized key: " + option.getKey());
}

Try / catch

try {
    result = option.test(info, result);
} catch (UnsupportedOperationException e) {
    Log.w(TAG, "Filter option key not supported", e);
    result.setMatched(false);
}

Prevention

When it happens

Trigger: A key in InstallerOption's key map lacking a case in test()'s switch; the protected `key` field set directly; stale keys from hand-crafted Parcels or reflection-based construction.

Common situations: Adding a new installer-matching key without updating test(); forked or modified builds; deserialization of crafted filter data.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/d0eae06ae9b61b79. Report an issue: GitHub.

Appendix: source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/filters/options/InstallerOption.java:74

                    }
                }
                return result.setMatched(false);
            case "installer_none":
                for (String installer: stringValues) {
                    if (installers.contains(installer)) {
                        return result.setMatched(false);
                    }
                }
                return result.setMatched(true);
            case "regex":
                for (String installer : installers) {
                    if (regexValue.matcher(installer).matches()) {
                        return result.setMatched(true);
                    }
                }
                return result.setMatched(false);
            default:
                throw new UnsupportedOperationException("Invalid key " + key);
        }
    }

    @NonNull
    private static Set<String> getInstallers(@NonNull InstallSourceInfoCompat installSourceInfo) {
        Set<String> installers = new LinkedHashSet<>();
        if (installSourceInfo.getInstallingPackageName() != null) {
            installers.add(installSourceInfo.getInstallingPackageName());
        }
        if (installSourceInfo.getInitiatingPackageName() != null) {
            installers.add(installSourceInfo.getInitiatingPackageName());
        }
        if (installSourceInfo.getOriginatingPackageName() != null) {
            installers.add(installSourceInfo.getOriginatingPackageName());
        }
        return installers;
    }

View on GitHub (pinned to 0152f468fc)