atuinsh/atuin · error

Your Hub session token is invalid. Please run 'atuin login'…

Error message

Your Hub session token is invalid. Please run 'atuin login' to re-authenticate with Atuin Hub.

What it means

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.

Solutions

  1. Re-authenticate: run `atuin login` to obtain a fresh `atapi_` token.
  2. Inspect the stored token and confirm it starts with `atapi_`.
  3. Clear stale auth state in the config directory if `atuin login` conflicts with existing credentials.
  4. Update Atuin if you are on a version predating Hub API tokens.

Example fix

// before: attempting password change with stale token
client.change_password(cur, new, totp).await?;
// after: re-login first
// $ atuin login -u <user>
// then retry the password change
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check the token shape before calling change_password
fn has_valid_hub_token(token: Option<&str>) -> bool {
    matches!(token, Some(t) if t.starts_with("atapi_"))
}

Try / catch

match client.change_password(cur, new, totp).await {
    Err(e) if e.to_string().contains("token is invalid") => {
        eprintln!("Run `atuin login` to refresh the Hub token");
    }
    other => { /* handle */ }
}

Prevention

When it happens

Trigger: 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.

Common situations: Upgraded Atuin installs where the login token predates the Hub `atapi_` scheme; manually edited or corrupted config files; tokens from a different sync provider.

Understand the failure class

Related errors


AI-assisted analysis of atuinsh/atuin@900007c480 (2026-09-19). Data as JSON: /api/errors/a0a826b058d74804. Report an issue: GitHub.

Appendix: source

Thrown at crates/atuin-client/src/auth.rs:367

        if let Ok(err) = resp.json::<HubErrorResponse>().await {
            bail!("{}", err.reason);
        }

        bail!("Hub registration failed with status {status}");
    }

    async fn change_password(
        &self,
        current_password: &str,
        new_password: &str,
        totp_code: Option<&str>,
    ) -> Result<MutateResponse> {
        let hub_token = self.hub_token.as_deref().ok_or_else(|| {
            eyre::eyre!("Not logged in to Atuin Hub. Please run 'atuin login' to authenticate.")
        })?;

        if !hub_token.starts_with("atapi_") {
            bail!(
                "Your Hub session token is invalid. Please run 'atuin login' to re-authenticate \
                 with Atuin Hub."
            );
        }

        let url = self.address.append_path("api/v0/account/password")?;
        let client = reqwest::Client::new();

        let mut body = serde_json::json!({
            "current_password": current_password,
            "new_password": new_password,
        });
        if let Some(code) = totp_code {
            body["totp_code"] = serde_json::Value::String(code.to_string());
        }

        let resp = client
            .patch(url)

View on GitHub (pinned to 900007c480)