{"record":{"id":"d98fe70893644168","repo":"jlcodes99/cockpit-tools","slug":"preparestartcontext-url","errorCode":null,"errorMessage":"网关 prepareStartContext 请求失败[{}]: {} (url={})","messagePattern":"网关 prepareStartContext 请求失败\\[(.+?)\\]: (.+?) \\(url=(.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/modules/wakeup.rs","lineNumber":1460,"sourceCode":"            cancel_rx,\n            client\n                .post(&prepare_url)\n                .header(reqwest::header::CONTENT_TYPE, \"application/json\")\n                .json(&json!({\n                    \"accountId\": account_id,\n                    \"model\": model,\n                    \"maxOutputTokens\": max_output_tokens,\n                }))\n                .send(),\n        )\n        .await?\n        .map_err(|e| {\n            let kind = classify_gateway_transport_error(&e);\n            let message = format!(\n                \"网关 prepareStartContext 请求失败[{}]: {} (url={})\",\n                kind, e, prepare_url\n            );\n            crate::modules::logger::log_error(&format!(\"[Wakeup] {}\", message));\n            message\n        })?\n        .error_for_status()\n        .map_err(|e| {\n            format!(\n                \"网关 prepareStartContext 返回错误: {} (url={})\",\n                e, prepare_url\n            )\n        })?;\n\n        start_resp = post_gateway_json(\n            &client,\n            &format!(\"{}/StartCascade\", service_base),\n            &json!({}),\n            \"StartCascade\",\n            cancel_rx,\n        )\n        .await?;","sourceCodeStart":1442,"sourceCodeEnd":1478,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src-tauri/src/modules/wakeup.rs#L1442-L1478","documentation":"trigger_wakeup_via_client_gateway_once first calls a prepareStartContext gateway endpoint before the main wakeup; a transport failure there is wrapped as '网关 prepareStartContext 请求失败[{kind}]: {err} (url={prepare_url})'. Like error 255, this is a pre-response transport failure, but specific to the prepareStartContext bootstrap step, so the whole wakeup cascade cannot begin.","triggerScenarios":"trigger_wakeup_via_client_gateway → trigger_wakeup_via_client_gateway_once sends the prepareStartContext POST and reqwest fails at DNS/connect/TLS/timeout before any HTTP status is received.","commonSituations":"Gateway host down or misconfigured; network offline/VPN drop at session start; TLS certificate problems on the prepare endpoint; client timeout set too low for a slow gateway; wrong environment base URL.","solutions":["Check the classified [kind] to pinpoint dns/connect/tls/timeout","Verify the prepareStartContext URL and gateway config for the active environment","Test connectivity to the gateway host directly (curl/ping)","Retry with backoff; the caller may fall back to alternate base URLs","If TLS-related, refresh CA certs or fix the server certificate"],"exampleFix":"// before\n.map_err(|e| {\n    let kind = classify_gateway_transport_error(&e);\n    let message = format!(\"网关 prepareStartContext 请求失败[{}]: {} (url={})\", kind, e, prepare_url);\n    crate::modules::logger::log_error(&format!(\"[Wakeup] {}\", message));\n    message\n})?;\n// after\n.map_err(|e| {\n    let kind = classify_gateway_transport_error(&e);\n    let message = format!(\"网关 prepareStartContext 请求失败[{}]: {} (url={})\", kind, e, prepare_url);\n    crate::modules::logger::log_error(&format!(\"[Wakeup] {}\", message));\n    retry_with_backoff_if_transient(kind); // e.g. connect/timeout only\n    message\n})?;","handlingStrategy":"retry","validationCode":"// Pre-flight reachability of the prepare endpoint before the wakeup cascade\nfn prepare_endpoint_ok(prepare_url: &str) -> bool {\n    reqwest::blocking::get(prepare_url).map(|r| !r.status().is_server_error()).unwrap_or(false)\n}","typeGuard":"fn is_prepare_transport_error(err: &str) -> bool { err.contains(\"prepareStartContext 请求失败\") }","tryCatchPattern":"match trigger_wakeup_via_client_gateway(req).await {\n    Err(e) if e.contains(\"prepareStartContext 请求失败\") => {\n        // bootstrap failed: back off, then retry with fallback base URL\n        sleep_backoff();\n        try_wakeup_with_next_base().await;\n    }\n    other => handle(other),\n}","preventionTips":["Health-check the prepare endpoint before starting cascades","Configure connect timeouts below the user-visible wait budget","Maintain fallback base URLs for the prepare step","Detect VPN/network drops at session start and defer wakeup"],"tags":["network","gateway","http-client","bootstrap"],"backgroundTag":"gateway-request-transport-failed","analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}