{"record":{"id":"a9d1e14b29ec145b","repo":"gitbutlerapp/gitbutler","slug":"failed-to-parse-response-e","errorCode":null,"errorMessage":"Failed to parse response: {e}","messagePattern":"Failed to parse response: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-update/src/check.rs","lineNumber":132,"sourceCode":"        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();\n        let (suppressed_at, suppress_duration_hours) = existing\n            .and_then(|cached| cached.suppressed_at.zip(cached.suppress_duration_hours))\n            .and_then(|(suppressed_at, duration_hours)| {\n                let suppress_until = suppressed_at + chrono::Duration::hours(duration_hours as i64);\n                if now > suppress_until {","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-update/src/check.rs#L114-L150","documentation":"Thrown when the response body from the update server cannot be deserialized into CheckUpdateStatus via serde_json. The request succeeded with a 2xx status, but the JSON payload does not match the expected schema (missing/renamed fields, wrong types, or non-JSON body).","triggerScenarios":"check_status/check_status_with_url calling response.json::<CheckUpdateStatus>() when the server returns HTML (e.g. a captive-portal or proxy page), an error body with 200, or JSON whose fields no longer match the CheckUpdateStatus struct (up_to_date, latest_version, release_notes, url, signature).","commonSituations":"Corporate proxy or captive portal injecting HTML into responses; API contract change between client and server versions; outdated app version talking to a newer update API; a URL override pointing at a mock/test server returning an unexpected body.","solutions":["Capture the raw response body and compare it against the CheckUpdateStatus fields to spot schema drift.","Check whether a proxy/captive portal is intercepting the response (body starts with '<' instead of '{').","Update the client application — an old client may be parsing a changed API schema.","If using check_status_with_url against a mock server, fix the mock's response to serialize a valid CheckUpdateStatus."],"exampleFix":"// before\nlet update_info = response\n    .json::<CheckUpdateStatus>()\n    .await\n    .map_err(|e| anyhow::anyhow!(\"Failed to parse response: {e}\"))?;\n// after: include the offending body for diagnosis\nlet text = response.text().await.map_err(|e| anyhow::anyhow!(\"Failed to read response: {e}\"))?;\nlet update_info: CheckUpdateStatus = serde_json::from_str(&text)\n    .map_err(|e| anyhow::anyhow!(\"Failed to parse response: {e}; body: {text}\"))?;","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match but_update::check_status(app, &settings, &mut cache) {\n    Err(e) if e.to_string().contains(\"Failed to parse response\") => {\n        // incompatible/intercepted response: fall back to cached status\n        log::warn!(\"unrecognized update response, using cache\");\n        Ok(cached_check_result())\n    }\n    other => other?,\n}","preventionTips":["Beware proxies/captive portals that rewrite HTTPS bodies; verify the response is JSON.","Keep client and server API schemas in lockstep; version the update API.","For tests, make mock servers serialize exactly the CheckUpdateStatus shape.","Fall back to the cached check result instead of failing the whole flow."],"tags":["json","deserialization","api","updater"],"backgroundTag":"json-unmarshal-failed","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"}