{"record":{"id":"85cf11808ea9b149","repo":"Kuberwastaken/claurst","slug":"failed-to-build-http-client","errorCode":null,"errorMessage":"Failed to build HTTP client: {}","messagePattern":"Failed to build HTTP client: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-rust/crates/mcp/src/oauth.rs","lineNumber":165,"sourceCode":"    verifier: &str,\n) -> String {\n    let challenge = pkce_challenge(verifier);\n    format!(\n        \"{}?client_id=claurst&redirect_uri={}&response_type=code&code_challenge={}&code_challenge_method=S256\",\n        authorization_endpoint,\n        urlencoding::encode(redirect_uri),\n        challenge,\n    )\n}\n\npub async fn fetch_oauth_metadata(server_url: &str) -> anyhow::Result<McpOAuthMetadata> {\n    let base_url = normalized_server_url(server_url);\n    let fallback = fallback_oauth_metadata(base_url);\n    let metadata_url = format!(\"{}/.well-known/oauth-authorization-server\", base_url);\n    let client = reqwest::Client::builder()\n        .timeout(Duration::from_secs(10))\n        .build()\n        .map_err(|e| anyhow::anyhow!(\"Failed to build HTTP client: {}\", e))?;\n\n    match client.get(&metadata_url).send().await {\n        Ok(resp) if resp.status().is_success() => {\n            let meta: serde_json::Value = resp\n                .json()\n                .await\n                .map_err(|e| anyhow::anyhow!(\"OAuth metadata parse error: {}\", e))?;\n            Ok(McpOAuthMetadata {\n                authorization_endpoint: meta\n                    .get(\"authorization_endpoint\")\n                    .and_then(|value| value.as_str())\n                    .unwrap_or(fallback.authorization_endpoint.as_str())\n                    .to_string(),\n                token_endpoint: meta\n                    .get(\"token_endpoint\")\n                    .and_then(|value| value.as_str())\n                    .unwrap_or(fallback.token_endpoint.as_str())\n                    .to_string(),","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/mcp/src/oauth.rs#L147-L183","documentation":"fetch_oauth_metadata() builds a reqwest HTTP client (10s timeout) to fetch the authorization server's well-known metadata document. If reqwest cannot construct the client (TLS backend init failure, proxy misconfiguration, runtime issues), the build error is wrapped and returned. Called by begin_mcp_auth and get_valid_mcp_token.","triggerScenarios":"reqwest::Client::builder().build() returns Err during fetch_oauth_metadata — typically TLS backend initialization failure or invalid global proxy/env settings.","commonSituations":"Static binaries missing system TLS roots; reqwest built without a TLS feature for the target platform; corporate proxy env vars (HTTPS_PROXY) malformed; embedded targets lacking the network stack.","solutions":["Read the wrapped reqwest error for the concrete cause (usually TLS or proxy)","Rebuild with a working TLS feature (e.g. rustls or native-tls) enabled","Unset/fix malformed proxy environment variables (HTTP_PROXY/HTTPS_PROXY)","Retry in a normal networked environment to rule out sandbox restrictions"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// sanity-check the URL is https and reachable before metadata fetch\nif !server_url.starts_with(\"https://\") {\n    anyhow::bail!(\"OAuth requires an https server URL\");\n}","typeGuard":null,"tryCatchPattern":"let client = reqwest::Client::builder()\n    .timeout(Duration::from_secs(10))\n    .build()\n    .map_err(|e| {\n        eprintln!(\"reqwest build failed (TLS/proxy?): {e}\");\n        e\n    })?;","preventionTips":["Build reqwest with a TLS feature appropriate for the target (rustls for static builds)","Keep proxy env vars valid or unset them for the auth process","Test metadata fetching with curl in the deployment environment"],"tags":["http","oauth","reqwest","tls"],"backgroundTag":"http-request-failed","analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}