{"record":{"id":"fcd2ea08bfca7f75","repo":"atuinsh/atuin","slug":"current-password-is-incorrect-fcd2ea","errorCode":null,"errorMessage":"current password is incorrect","messagePattern":"current password is incorrect","errorType":"http","errorClass":null,"httpStatus":401,"severity":"error","filePath":"crates/atuin-client/src/auth.rs","lineNumber":205,"sourceCode":"        new_password: &str,\n        _totp_code: Option<&str>,\n    ) -> Result<MutateResponse> {\n        let client = self.authenticated_client()?;\n        let url = self.address.append_path(\"account/password\")?;\n\n        let resp = client\n            .patch(url)\n            .json(&ChangePasswordRequest {\n                current_password: current_password.to_string(),\n                new_password: new_password.to_string(),\n            })\n            .send()\n            .await?;\n\n        match resp.status().as_u16() {\n            200 => Ok(MutateResponse::Success),\n            401 => {\n                bail!(\"current password is incorrect\");\n            }\n            403 => {\n                bail!(\"invalid login details\");\n            }\n            _ => {\n                bail!(\"unknown error\");\n            }\n        }\n    }\n\n    async fn delete_account(\n        &self,\n        password: &str,\n        _totp_code: Option<&str>,\n    ) -> Result<MutateResponse> {\n        let client = self.authenticated_client()?;\n        let url = self.address.append([\"account\"])?;\n","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/atuinsh/atuin/blob/900007c48045867e7f44b0f9bc55ad9dbe99ee0d/crates/atuin-client/src/auth.rs#L187-L223","documentation":"In `HubAuthClient`'s/legacy `change_password`, HTTP 401 from the `PATCH account/password` call is mapped to this bail. 401 means the authentication attached to the request was rejected — here specifically the server declined because the supplied current password does not match the account. The library turns the bare status into this user-facing message.","triggerScenarios":"Calling `change_password(current_password, new_password)` where `current_password` is wrong or stale, or where the session token is expired/invalid so the server cannot authenticate the request at all.","commonSituations":"Typos or stale credentials in scripts/CI calling `atuin account` password change; the stored login session expired so 401 is about the token, not the password; password was already changed elsewhere (another machine) making the current password out of date.","solutions":["Re-enter the current password carefully and retry the change","Verify the account's current password by logging in fresh (`atuin login`) to rule out an expired session token","Re-authenticate to obtain a new session, then retry `change_password`","If the password was rotated on another device, use that newest password as the current one"],"exampleFix":"// before: cannot distinguish bad password from expired session\nmatch resp.status().as_u16() {\n    401 => bail!(\"current password is incorrect\"),\n// after: verify credentials with a fresh login first\nlet reauth = auth.login(username, current_password, None).await?;\nassert!(matches!(reauth, AuthResponse::Success { .. }));\n// then proceed with change_password","handlingStrategy":"validation","validationCode":"// Verify the current password by attempting a fresh login before changing it\nlet check = auth_client.login(username, current_password, totp).await?;\nif !matches!(check, AuthResponse::Success { .. }) {\n    bail!(\"current password does not authenticate; aborting change\");\n}","typeGuard":"fn is_wrong_current_password(err: &Report) -> bool {\n    err.to_string().contains(\"current password is incorrect\")\n}","tryCatchPattern":"match auth_client.change_password(current, new, totp).await {\n    Ok(MutateResponse::Success) => println!(\"password updated\"),\n    Err(e) if e.to_string().contains(\"current password is incorrect\") => {\n        eprintln!(\"re-authenticate with the correct current password and retry\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Confirm the current password with a test login before changing it","Re-login to refresh expired sessions before account operations","Update stored credentials on all machines after any password rotation","Avoid scripting password changes with credentials read from stale env vars"],"tags":["http","authentication","atuin","password"],"backgroundTag":"authentication-required","analyzedSha":"900007c48045867e7f44b0f9bc55ad9dbe99ee0d","analyzedAt":"2026-09-19T12:52:51.491Z","contentChangedAt":"2026-09-19T12:52:51.491Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}