{"record":{"id":"7b9cb9624bf6ae35","repo":"tinyhumansai/openhuman","slug":"aes-gcm-decrypt-failed-e","errorCode":null,"errorMessage":"AES-GCM decrypt failed: {e}","messagePattern":"AES-GCM decrypt failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/api/rest.rs","lineNumber":1162,"sourceCode":"    let ciphertext = &combined[32..];\n\n    // aes-gcm expects ciphertext || tag\n    let mut ct_with_tag = Vec::with_capacity(ciphertext.len() + tag.len());\n    ct_with_tag.extend_from_slice(ciphertext);\n    ct_with_tag.extend_from_slice(tag);\n\n    use aes_gcm::aead::generic_array::typenum::U16;\n    use aes_gcm::aead::{Aead, KeyInit};\n    use aes_gcm::aes::Aes256;\n    use aes_gcm::AesGcm;\n    type Aes256Gcm16 = AesGcm<Aes256, U16>;\n\n    let cipher =\n        Aes256Gcm16::new_from_slice(&key).map_err(|e| anyhow::anyhow!(\"invalid AES key: {e}\"))?;\n    let nonce = aes_gcm::aead::generic_array::GenericArray::from_slice(iv);\n    let plain = cipher\n        .decrypt(nonce, ct_with_tag.as_ref())\n        .map_err(|e| anyhow::anyhow!(\"AES-GCM decrypt failed: {e}\"))?;\n\n    String::from_utf8(plain).context(\"handoff plaintext is not UTF-8\")\n}\n\n/// Decode the shared encryption key into 32 raw AES bytes.\n///\n/// Accepts, in order of preference:\n/// 1. base64url without padding — the current backend format (e.g.\n///    a 43-char alphanumeric string using `-` / `_`). This must be tried\n///    BEFORE standard base64 because `-`/`_` are invalid in the standard\n///    alphabet and would fail cleanly, whereas a standard-base64 string\n///    never contains `-`/`_` so base64url_no_pad will still decode it\n///    correctly as long as there's no padding.\n/// 2. base64url with padding.\n/// 3. Standard base64 with padding (legacy backend format).\n/// 4. Standard base64 without padding.\n/// 5. A raw 32-byte ASCII key (len == 32, used as-is).\n///","sourceCodeStart":1144,"sourceCodeEnd":1180,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/api/rest.rs#L1144-L1180","documentation":"AEAD decryption failure in decrypt_handoff_blob: the AES-256-GCM open() on the reassembled nonce+ciphertext+tag failed. GCM failure means authentication, not I/O: the tag did not verify — wrong key, corrupted/truncated blob, or a tampered payload. The original aes-gcm error is wrapped with this message and the handoff token fetch aborts.","triggerScenarios":"Thrown at src/api/rest.rs:1162 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the key matches the one that encrypted the handoff blob (same pairing/session)","Re-request the handoff blob — truncation in transit produces the same tag failure","Treat persistent failures across fresh blobs as a key-derivation mismatch: re-pair rather than retrying blindly"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}