atuinsh/atuin · error
invalid two-factor code
Error message
invalid two-factor code
What it means
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.
Source
Thrown at crates/atuin-client/src/auth.rs:404
.header(USER_AGENT, APP_USER_AGENT)
.header(ATUIN_HEADER_VERSION, ATUIN_CARGO_VERSION)
.bearer_auth(hub_token)
.json(&body)
.send()
.await
.context("failed to connect to Atuin Hub")?;
let status = resp.status();
if status.is_success() {
return Ok(MutateResponse::Success);
}
if let Ok(err) = resp.json::<HubErrorResponse>().await {
match err.code.as_deref() {
Some("2fa_required") => return Ok(MutateResponse::TwoFactorRequired),
Some("invalid_2fa_code") => {
bail!("invalid two-factor code");
}
_ => {
bail!("{}", err.reason);
}
}
}
match status {
StatusCode::UNAUTHORIZED => {
bail!("current password is incorrect");
}
StatusCode::FORBIDDEN => {
bail!("invalid login details");
}
_ => {
bail!("Hub password change failed with status {status}");
}
}View on GitHub (pinned to c0c717ab04)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/atuin-client/src/auth.rs:404 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of atuinsh/atuin@c0c717ab04 (2026-09-12).
Data as JSON: /api/errors/ac16d8bd876d3e89.
Report an issue: GitHub.