beemdevelopment/Aegis · error

Bad URI format

Error message

Bad URI format

What it means

Generic guard in parseExportUri(String): thrown when Uri.parse(s) returns null for the given export URI string, meaning the input could not be parsed as a URI at all. It fires on syntactically invalid or empty strings passed to vault export/import handling before any content is inspected.

Solutions

  1. Verify the string is a complete export URI with the expected scheme before calling parseExportUri
  2. Catch GoogleAuthInfoException and prompt the user to re-scan/re-share the export
  3. Check the intent/clipboard source isn't returning empty or transformed text

Example fix

// before
GoogleAuthInfo.Export export = GoogleAuthInfo.parseExportUri(data);
// after
if (data != null && data.contains("://")) {
    GoogleAuthInfo.Export export = GoogleAuthInfo.parseExportUri(data);
} else {
    throw new GoogleAuthInfoException(null, "Invalid export URI");
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (s == null || !s.contains("://")) throw new IllegalArgumentException("not a URI");

Try / catch

try { GoogleAuthInfo.Export e = GoogleAuthInfo.parseExportUri(s); } catch (GoogleAuthInfoException ex) { showInvalidExportError(); }

Prevention

When it happens

Trigger: Calling parseExportUri(s) with a null or unparseable string s.

Common situations: Passing a raw JSON/text export instead of an aegis:// (otpauth-migration style) URI, or a truncated string from an intent/clipboard read.

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

Appendix: source

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

        } catch (OtpInfoException | NumberFormatException e) {
            throw new GoogleAuthInfoException(uri, e);
        }

        return new GoogleAuthInfo(info, accountName, issuer);
    }

    /**
     * Decodes the given base 32 secret, while being tolerant of whitespace and dashes.
     */
    public static byte[] parseSecret(String s) throws EncodingException {
        s = s.trim().replace("-", "").replace(" ", "");
        return Base32.decode(s);
    }

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

    public static Export parseExportUri(Uri uri) throws GoogleAuthInfoException {
        String scheme = uri.getScheme();
        if (scheme == null || !scheme.equals(SCHEME_EXPORT)) {
            throw new GoogleAuthInfoException(uri, "Unsupported protocol");
        }

        String host = uri.getHost();
        if (host == null || !host.equals("offline")) {
            throw new GoogleAuthInfoException(uri, "Unsupported host");
        }

        String data = uri.getQueryParameter("data");
        if (data == null) {
            throw new GoogleAuthInfoException(uri, "Parameter 'data' is not set");

View on GitHub (pinned to d6f4e5925a)