{"record":{"id":"a0a826b058d74804","repo":"atuinsh/atuin","slug":"your-hub-session-token-is-invalid-please-run-atu","errorCode":null,"errorMessage":"Your Hub session token is invalid. Please run 'atuin login' to re-authenticate with Atuin Hub.","messagePattern":"Your Hub session token is invalid\\. Please run 'atuin login' to re-authenticate with Atuin Hub\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/atuin-client/src/auth.rs","lineNumber":367,"sourceCode":"        if let Ok(err) = resp.json::<HubErrorResponse>().await {\n            bail!(\"{}\", err.reason);\n        }\n\n        bail!(\"Hub registration failed with status {status}\");\n    }\n\n    async fn change_password(\n        &self,\n        current_password: &str,\n        new_password: &str,\n        totp_code: Option<&str>,\n    ) -> Result<MutateResponse> {\n        let hub_token = self.hub_token.as_deref().ok_or_else(|| {\n            eyre::eyre!(\"Not logged in to Atuin Hub. Please run 'atuin login' to authenticate.\")\n        })?;\n\n        if !hub_token.starts_with(\"atapi_\") {\n            bail!(\n                \"Your Hub session token is invalid. Please run 'atuin login' to re-authenticate \\\n                 with Atuin Hub.\"\n            );\n        }\n\n        let url = self.address.append_path(\"api/v0/account/password\")?;\n        let client = reqwest::Client::new();\n\n        let mut body = serde_json::json!({\n            \"current_password\": current_password,\n            \"new_password\": new_password,\n        });\n        if let Some(code) = totp_code {\n            body[\"totp_code\"] = serde_json::Value::String(code.to_string());\n        }\n\n        let resp = client\n            .patch(url)","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/atuinsh/atuin/blob/900007c48045867e7f44b0f9bc55ad9dbe99ee0d/crates/atuin-client/src/auth.rs#L349-L385","documentation":"Pre-flight guard in `change_password` (crates/atuin-client/src/auth.rs:367): the stored Hub token exists but does not start with `atapi_`, so it cannot be a valid Hub API token. The client refuses to send a request that would certainly fail authentication.","triggerScenarios":"Calling `atuin account password change` (or equivalent) while the local config holds a legacy/non-Hub session token (e.g. a pre-Hub `atuin login` session) instead of an `atapi_` API token.","commonSituations":"Upgraded Atuin installs where the login token predates the Hub `atapi_` scheme; manually edited or corrupted config files; tokens from a different sync provider.","solutions":["Re-authenticate: run `atuin login` to obtain a fresh `atapi_` token.","Inspect the stored token and confirm it starts with `atapi_`.","Clear stale auth state in the config directory if `atuin login` conflicts with existing credentials.","Update Atuin if you are on a version predating Hub API tokens."],"exampleFix":"// before: attempting password change with stale token\nclient.change_password(cur, new, totp).await?;\n// after: re-login first\n// $ atuin login -u <user>\n// then retry the password change","handlingStrategy":"validation","validationCode":"// Pre-check the token shape before calling change_password\nfn has_valid_hub_token(token: Option<&str>) -> bool {\n    matches!(token, Some(t) if t.starts_with(\"atapi_\"))\n}","typeGuard":null,"tryCatchPattern":"match client.change_password(cur, new, totp).await {\n    Err(e) if e.to_string().contains(\"token is invalid\") => {\n        eprintln!(\"Run `atuin login` to refresh the Hub token\");\n    }\n    other => { /* handle */ }\n}","preventionTips":["Re-run `atuin login` after upgrading Atuin versions.","Never hand-edit stored auth tokens.","Check the token prefix (`atapi_`) before performing account operations."],"tags":["auth","token","api"],"backgroundTag":"missing-credentials","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"}