{"record":{"id":"ac16d8bd876d3e89","repo":"atuinsh/atuin","slug":"invalid-two-factor-code","errorCode":null,"errorMessage":"invalid two-factor code","messagePattern":"invalid two-factor code","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/atuin-client/src/auth.rs","lineNumber":404,"sourceCode":"            .header(USER_AGENT, APP_USER_AGENT)\n            .header(ATUIN_HEADER_VERSION, ATUIN_CARGO_VERSION)\n            .bearer_auth(hub_token)\n            .json(&body)\n            .send()\n            .await\n            .context(\"failed to connect to Atuin Hub\")?;\n\n        let status = resp.status();\n\n        if status.is_success() {\n            return Ok(MutateResponse::Success);\n        }\n\n        if let Ok(err) = resp.json::<HubErrorResponse>().await {\n            match err.code.as_deref() {\n                Some(\"2fa_required\") => return Ok(MutateResponse::TwoFactorRequired),\n                Some(\"invalid_2fa_code\") => {\n                    bail!(\"invalid two-factor code\");\n                }\n                _ => {\n                    bail!(\"{}\", err.reason);\n                }\n            }\n        }\n\n        match status {\n            StatusCode::UNAUTHORIZED => {\n                bail!(\"current password is incorrect\");\n            }\n            StatusCode::FORBIDDEN => {\n                bail!(\"invalid login details\");\n            }\n            _ => {\n                bail!(\"Hub password change failed with status {status}\");\n            }\n        }","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/atuinsh/atuin/blob/c0c717ab04c881764bcad4b3d169a507e2432643/crates/atuin-client/src/auth.rs#L386-L422","documentation":"HubErrorCode dispatch in the auth-module change_password: the server returned a structured HubErrorResponse with code 'invalid_2fa_code', meaning the TOTP/2FA code supplied alongside the password change did not verify. The password was not changed.","triggerScenarios":"Thrown at crates/atuin-client/src/auth.rs:404 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Generate a fresh 2FA code (codes rotate every ~30s) and retry","Verify the device clock is accurate, as drift invalidates TOTP codes","Re-enroll 2FA if codes persistently fail"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c0c717ab04c881764bcad4b3d169a507e2432643","analyzedAt":"2026-09-12T07:40:01.341Z","contentChangedAt":"2026-09-12T07:40:01.341Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}