{"record":{"id":"b66d9a8c100b918c","repo":"beemdevelopment/Aegis","slug":"bad-secret","errorCode":null,"errorMessage":"Bad secret","messagePattern":"Bad secret","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/main/java/com/beemdevelopment/aegis/otp/GoogleAuthInfo.java","lineNumber":60,"sourceCode":"    }\n\n    public static GoogleAuthInfo parseUri(Uri uri) throws GoogleAuthInfoException {\n        String scheme = uri.getScheme();\n        if (scheme == null || !(scheme.equals(SCHEME) || scheme.equals(MotpInfo.SCHEME))) {\n            throw new GoogleAuthInfoException(uri, String.format(\"Unsupported protocol: %s\", scheme));\n        }\n\n        // 'secret' is a required parameter\n        String encodedSecret = uri.getQueryParameter(\"secret\");\n        if (encodedSecret == null) {\n            throw new GoogleAuthInfoException(uri, \"Parameter 'secret' is not present\");\n        }\n\n        byte[] secret;\n        try {\n            secret = (scheme.equals(MotpInfo.SCHEME)) ? Hex.decode(encodedSecret) : parseSecret(encodedSecret);\n        } catch (EncodingException e) {\n            throw new GoogleAuthInfoException(uri, \"Bad secret\", e);\n        }\n        if (secret.length == 0) {\n            throw new GoogleAuthInfoException(uri, \"Secret is empty\");\n        }\n\n        OtpInfo info;\n        String issuer = \"\";\n        try {\n            String type = (scheme.equals(MotpInfo.SCHEME)) ? MotpInfo.ID : uri.getHost();\n            if (type == null) {\n                throw new GoogleAuthInfoException(uri, String.format(\"Host not present in URI: %s\", uri.toString()));\n            }\n\n            switch (type) {\n                case \"totp\":\n                    TotpInfo totpInfo = new TotpInfo(secret);\n                    String period = uri.getQueryParameter(\"period\");\n                    if (period != null) {","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/beemdevelopment/Aegis/blob/d6f4e5925a97e4e91593f1542085eae03432a759/app/src/main/java/com/beemdevelopment/aegis/otp/GoogleAuthInfo.java#L42-L78","documentation":"The 'secret' parameter was present but could not be decoded: Base32 decoding failed (for otpauth) or Hex decoding failed (for motp), raising an EncodingException that is wrapped in GoogleAuthInfoException with message 'Bad secret'.","triggerScenarios":"parseUri(Uri) with a secret containing characters outside the Base32 alphabet (or non-hex chars for motp), wrong casing/padding, or a URL-encoded secret not properly decoded.","commonSituations":"Manually typing a secret with O/0 or 1/I confusion, copying a hex secret into a totp URI, truncating the secret, or whitespace/newline contamination from copy-paste.","solutions":["Confirm the secret is valid Base32 (A-Z, 2-7, '=' padding) for otpauth URIs, or hex for motp","Re-copy the secret from the provider, removing spaces and newlines","Use a Base32/Hex library to validate the secret before building the URI"],"exampleFix":"// before\nString uri = \"otpauth://totp/x?secret=not_base32!!\";\n// after\nString secret = \"JBSWY3DPEHPK3PXP\"; // valid Base32\nString uri = \"otpauth://totp/x?secret=\" + secret;","handlingStrategy":"validation","validationCode":"if (!secret.matches(\"[A-Z2-7=]+\")) throw new IllegalArgumentException(\"secret is not valid Base32\");","typeGuard":null,"tryCatchPattern":"try { return GoogleAuthInfo.parseUri(uri); } catch (GoogleAuthInfoException e) { if (e.getMessage().contains(\"Bad secret\")) showBadSecretHint(); return null; }","preventionTips":["Sanitize secrets: uppercase, strip whitespace/newlines","Use standard Base32 (RFC 4648) when generating URIs","Distinguish hex secrets (motp) from Base32 (otpauth)"],"tags":["android","otp","base32","encoding","secret"],"backgroundTag":"invalid-argument-format","analyzedSha":"d6f4e5925a97e4e91593f1542085eae03432a759","analyzedAt":"2026-09-08T00:46:31.111Z","contentChangedAt":"2026-09-08T00:46:31.111Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}