beemdevelopment/Aegis · error

Unsupported protocol

Error message

Unsupported protocol: %s

What it means

Thrown by GoogleAuthInfo.parseUri(Uri) when the otpauth/motp URI's scheme is null or not one of the supported schemes ("otpauth" or MotpInfo.SCHEME). It fires when a user imports or pastes a malformed or non-2FA URI, acting as the protocol validation gate before any OTP parameters are read.

Solutions

  1. Check uri.getScheme() equals "otpauth" (or "motp") before calling parseUri
  2. Ensure the QR scanner returns the raw URI text without stripping the scheme
  3. Catch GoogleAuthInfoException and tell the user the code is not a supported 2FA URI

Example fix

// before
Uri uri = Uri.parse(scanned);
GoogleAuthInfo info = GoogleAuthInfo.parseUri(uri);
// after
Uri uri = Uri.parse(scanned);
if (uri.getScheme() != null && uri.getScheme().equals("otpauth")) {
    GoogleAuthInfo info = GoogleAuthInfo.parseUri(uri);
} else {
    throw new GoogleAuthInfoException(uri, "Not an otpauth URI");
}
Defensive patterns

Strategy: validation

Validate before calling

Uri uri = Uri.parse(s); if (uri.getScheme() == null || !(uri.getScheme().equals("otpauth") || uri.getScheme().equals("motp"))) return null;

Type guard

boolean isOtpUri(Uri u) { String s = u.getScheme(); return s != null && (s.equals("otpauth") || s.equals("motp")); }

Try / catch

try { return GoogleAuthInfo.parseUri(uri); } catch (GoogleAuthInfoException e) { Log.w(TAG, "Unsupported URI: " + uri); return null; }

Prevention

When it happens

Trigger: GoogleAuthInfo.parseUri(Uri) called with a URI whose getScheme() is null or not 'otpauth'/'motp' (e.g. https://, http://, or a scheme-less string).

Common situations: Importing an arbitrary web link by mistake, scanning a non-2FA QR code (URL, wifi config, vcard), or passing an already-decoded text payload that isn't an otpauth URI.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of beemdevelopment/Aegis@d6f4e5925a (2026-09-08). Data as JSON: /api/errors/95edd84e58ed7984. Report an issue: GitHub.

Appendix: source

Thrown at app/src/main/java/com/beemdevelopment/aegis/otp/GoogleAuthInfo.java:47

    public GoogleAuthInfo(OtpInfo info, String accountName, String issuer) {
        _info = info;
        _accountName = accountName;
        _issuer = issuer;
    }

    public static GoogleAuthInfo parseUri(String s) throws GoogleAuthInfoException {
        Uri uri = Uri.parse(s);
        if (uri == null) {
            throw new GoogleAuthInfoException(uri, String.format("Bad URI format: %s", s));
        }
        return GoogleAuthInfo.parseUri(uri);
    }

    public static GoogleAuthInfo parseUri(Uri uri) throws GoogleAuthInfoException {
        String scheme = uri.getScheme();
        if (scheme == null || !(scheme.equals(SCHEME) || scheme.equals(MotpInfo.SCHEME))) {
            throw new GoogleAuthInfoException(uri, String.format("Unsupported protocol: %s", scheme));
        }

        // 'secret' is a required parameter
        String encodedSecret = uri.getQueryParameter("secret");
        if (encodedSecret == null) {
            throw new GoogleAuthInfoException(uri, "Parameter 'secret' is not present");
        }

        byte[] secret;
        try {
            secret = (scheme.equals(MotpInfo.SCHEME)) ? Hex.decode(encodedSecret) : parseSecret(encodedSecret);
        } catch (EncodingException e) {
            throw new GoogleAuthInfoException(uri, "Bad secret", e);
        }
        if (secret.length == 0) {
            throw new GoogleAuthInfoException(uri, "Secret is empty");
        }

View on GitHub (pinned to d6f4e5925a)