{"record":{"id":"6153cf1f496e7e03","repo":"atuinsh/atuin","slug":"failed-to-parse-server-version","errorCode":null,"errorMessage":"failed to parse server version: {:?}","messagePattern":"failed to parse server version: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/atuin-client/src/api_client.rs","lineNumber":208,"sourceCode":"    let client = reqwest::Client::new();\n\n    let resp = client.get(url).header(USER_AGENT, APP_USER_AGENT).send().await?;\n    let resp = handle_resp_error(resp).await?;\n\n    let index = resp.json::<IndexResponse>().await?;\n    let version = Version::parse(index.version.as_str())?;\n\n    Ok(version)\n}\n\npub fn ensure_version(response: &Response) -> Result<bool> {\n    let version = response.headers().get(ATUIN_HEADER_VERSION);\n\n    let version = if let Some(version) = version {\n        match version.to_str() {\n            Ok(v) => Version::parse(v),\n            Err(e) => {\n                bail!(\"failed to parse server version: {:?}\", e);\n            }\n        }\n    } else {\n        bail!(\"Server not reporting its version: it is either too old or unhealthy\");\n    }?;\n\n    // If the client is newer than the server\n    if version.major < ATUIN_VERSION.major {\n        println!(\n            \"Atuin version mismatch! In order to successfully sync, the server needs to run a \\\n             newer version of Atuin\"\n        );\n        println!(\"Client: {ATUIN_CARGO_VERSION}\");\n        println!(\"Server: {version}\");\n\n        return Ok(false);\n    }\n","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/atuinsh/atuin/blob/c0c717ab04c881764bcad4b3d169a507e2432643/crates/atuin-client/src/api_client.rs#L190-L226","documentation":"`ensure_version` reads the `x-atuin-version` header from a server response and parses it as a semver `Version`. If the header is present but is not valid UTF-8 (`to_str` fails), the error bails with the underlying `ToStrError` debug-formatted.","triggerScenarios":"A response from the sync server has a version header that is not valid header-value UTF-8 — typically caused by a middleware/proxy injecting a malformed header value","commonSituations":"Misconfigured reverse proxy or custom atuin-server fork emitting a corrupt `x-atuin-version` header during register/login/record_status","solutions":["Inspect the raw response header `x-atuin-version` (curl -i) and fix its value","Check reverse proxy/middleware for header rewriting bugs","Upgrade or restart the sync server so it emits a clean semver version"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// validate the header is clean UTF-8 semver before use\nlet raw = resp.headers().get(\"x-atuin-version\")\n    .and_then(|v| v.to_str().ok())\n    .and_then(|v| Version::parse(v).ok());\nif raw.is_none() {\n    eprintln!(\"server returned an unparsable x-atuin-version\");\n}","typeGuard":null,"tryCatchPattern":"match ensure_version(&resp) {\n    Err(e) if e.to_string().contains(\"failed to parse server version\") => {\n        eprintln!(\"check your proxy/server for a malformed x-atuin-version header\");\n    }\n    other => other?,\n}","preventionTips":["Inspect outbound headers with curl -i after proxy changes","Avoid middleware that mutates x-atuin-version","Test server behind proxies with version-sensitive endpoints"],"tags":["http","version","parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"c0c717ab04c881764bcad4b3d169a507e2432643","analyzedAt":"2026-09-12T07:40:01.341Z","contentChangedAt":"2026-09-12T07:40:01.341Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}