atuinsh/atuin · error

There was an error with the atuin sync service at

Error message

There was an error with the atuin sync service at {url}, Status {status:?}.
Response body: {body}
If the problem persists, contact the host

What it means

The fallback branch of `handle_resp_error`: the server returned a non-success status but its body could NOT be parsed as an atuin `ErrorResponse` JSON. The client includes the raw response body and status so you can see what actually answered — often a proxy, load balancer, or an unexpected server response.

Solutions

  1. Inspect the response body shown in the message — it usually names the real culprit (proxy, DNS, etc.)
  2. Verify `sync_address` in your atuin config resolves to the actual atuin server
  3. Check proxy/CDN logs if a load balancer sits in front of your server
  4. Confirm network connectivity and that no captive portal/SSL inspection is intercepting requests
Defensive patterns

Strategy: fallback

Validate before calling

// Sanity-check the sync address before making requests
let url = url::Url::parse(&sync_address)?;
anyhow::ensure!(url.scheme() == "https", "sync_address must use https");

Try / catch

match client.me().await {
    Err(e) if e.to_string().contains("Response body") => {
        // Unparseable body: likely a proxy or wrong host; log full message for diagnosis
        eprintln!("Unexpected server response: {e}");
    }
    other => other,
}

Prevention

When it happens

Trigger: register, login, latest_version, page, me, or delete_store receiving a non-2xx response whose body is not `{"reason": ...}` JSON — HTML error pages, empty bodies, plain-text proxy errors.

Common situations: A reverse proxy (nginx/Cloudflare) returns an HTML 502/504 error page; a captive portal or corporate proxy intercepts the TLS connection; the server is a different version returning unexpected error shapes; hitting the wrong URL entirely (e.g. a placeholder sync address).

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at crates/atuin-client/src/api_client.rs:261

    }

    if !status.is_success() {
        let body = resp.text().await.unwrap_or_default();

        if let Ok(error) = serde_json::from_str::<ErrorResponse>(&body) {
            let reason = error.reason;

            if status.is_client_error() {
                bail!("Invalid request to the service at {url}, {status} - {reason}.");
            }

            bail!(
                "There was an error with the atuin sync service at {url}, server error {status}: \
                 {reason}.\nIf the problem persists, contact the host"
            );
        }

        bail!(
            "There was an error with the atuin sync service at {url}, Status \
             {status:?}.\nResponse body: {body}\nIf the problem persists, contact the host"
        );
    }

    Ok(resp)
}

/// Build the capability reader for a sync server.
#[instrument(level = "trace", skip_all, err)]
pub fn caps_client(settings: &Settings) -> Result<Arc<CapClient>> {
    let auth_settings = Arc::new(settings.clone());

    let auth = AuthHeaderProvider::new(move || {
        let settings = auth_settings.clone();
        Box::pin(async move { settings.sync_auth_token().await.ok().map(|t| t.to_header_value()) })
    });

View on GitHub (pinned to 900007c480)