{"record":{"id":"bf05f9ed177bac21","repo":"gitbutlerapp/gitbutler","slug":"server-returned-error-e","errorCode":null,"errorMessage":"Server returned error: {e}","messagePattern":"Server returned error: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-update/src/check.rs","lineNumber":127,"sourceCode":"        .build()?;\n\n    let url = url_override.unwrap_or(UPDATES_CHECK_URL).to_string();\n\n    let result = std::thread::spawn(move || -> anyhow::Result<CheckUpdateStatus> {\n        let runtime = tokio::runtime::Builder::new_current_thread()\n            .enable_all()\n            .build()\n            .map_err(|e| anyhow::anyhow!(\"Failed to create runtime: {e}\"))?;\n\n        runtime.block_on(async {\n            let response = client\n                .post(url)\n                .json(&request_body)\n                .send()\n                .await\n                .map_err(|e| anyhow::anyhow!(\"Request failed: {e}\"))?\n                .error_for_status()\n                .map_err(|e| anyhow::anyhow!(\"Server returned error: {e}\"))?;\n\n            let update_info = response\n                .json::<CheckUpdateStatus>()\n                .await\n                .map_err(|e| anyhow::anyhow!(\"Failed to parse response: {e}\"))?;\n\n            Ok(update_info)\n        })\n    })\n    .join()\n    .map_err(|_| anyhow::anyhow!(\"Update check thread panicked\"))?;\n\n    // Save to cache (convert to but_db types)\n    if let Ok(status) = &result {\n        let now = chrono::Utc::now();\n\n        // Get existing cache to preserve suppression\n        let existing = trans.update_check().get();","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-update/src/check.rs#L109-L145","documentation":"Thrown when the update server responds with an HTTP error status (4xx/5xx); error_for_status() converts the successful transport response into an error carrying the status code and URL. The request reached the server but the server rejected or failed to process it.","triggerScenarios":"check_status/check_status_with_url receiving a 4xx or 5xx response from the update endpoint — e.g. 401 when the X-Auth-Token from secret::retrieve(\"gitbutler_access_token\") is missing/invalid, 400 for a malformed CheckUpdatesRequest (bad channel/os/arch/version), or 5xx during a server-side incident.","commonSituations":"Expired or revoked access token in the secret store; nightly channel builds hitting an endpoint that rejects the channel/os/arch combination; server outage returning 500/502/503; a stale build sending an unrecognized version string.","solutions":["Inspect the HTTP status in the wrapped reqwest error and match the fix to it (401/403 → re-authenticate; 4xx → check channel/version payload; 5xx → retry later).","Re-login to refresh the gitbutler_access_token secret if the status is 401/403.","Retry the update check after a short delay if the status is 5xx (server-side issue).","Verify the build's CHANNEL/VERSION env vars are sane; a corrupt channel value can trigger client-side rejection."],"exampleFix":"// before\nlet response = client.post(url).json(&request_body).send().await\n    .map_err(|e| anyhow::anyhow!(\"Request failed: {e}\"))?\n    .error_for_status()\n    .map_err(|e| anyhow::anyhow!(\"Server returned error: {e}\"))?;\n// after: tolerate server errors and fall back to cached status\nlet response = match client.post(&url).json(&request_body).send().await {\n    Ok(r) => r,\n    Err(_) => return Ok(cached_status),\n};\nlet response = match response.error_for_status() {\n    Ok(r) => r,\n    Err(err) if err.status().is_some_and(|s| s.is_server_error()) => return Ok(cached_status),\n    Err(e) => return Err(anyhow::anyhow!(\"Server returned error: {e}\")),\n};","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match but_update::check_status(app, &settings, &mut cache) {\n    Err(e) if e.to_string().contains(\"Server returned error\") => {\n        // server rejected the request: use cached update status\n        Ok(cached_check_result())\n    }\n    other => other?,\n}","preventionTips":["Keep the access token fresh (re-login when 401/403 occurs).","Only send channel/os/arch/version values produced by the build system.","Retry with backoff on 5xx instead of surfacing the error to users.","Monitor server health before hard-failing the update flow."],"tags":["http","server-error","updater","api"],"backgroundTag":"http-error-response","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}