{"record":{"id":"c9fe08dc27584b9a","repo":"tonhowtf/omniget","slug":"failed-to-build-http-client","errorCode":null,"errorMessage":"Failed to build HTTP client: {}","messagePattern":"Failed to build HTTP client: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/platforms/direct_file.rs","lineNumber":248,"sourceCode":"            .connect_timeout(std::time::Duration::from_secs(30));\n\n        if let Some(ua) = opts.user_agent.as_deref() {\n            builder = builder.user_agent(ua);\n        }\n\n        let jar =\n            crate::core::cookie_parser::load_extension_cookies_for_url(file_url).or_else(|| {\n                opts.referer\n                    .as_deref()\n                    .and_then(crate::core::cookie_parser::load_extension_cookies_for_url)\n            });\n        if let Some(jar) = jar {\n            builder = builder.cookie_provider(jar);\n        }\n\n        let client = builder\n            .build()\n            .map_err(|e| anyhow!(\"Failed to build HTTP client: {}\", e))?;\n\n        let mut headers = reqwest::header::HeaderMap::new();\n        if let Some(ref r) = opts.referer {\n            if let Ok(val) = reqwest::header::HeaderValue::from_str(r) {\n                headers.insert(reqwest::header::REFERER, val);\n            }\n        }\n        if let Some(ref hdrs) = opts.extra_headers {\n            for (name, value) in hdrs {\n                if let (Ok(hname), Ok(hval)) = (\n                    reqwest::header::HeaderName::from_bytes(name.as_bytes()),\n                    reqwest::header::HeaderValue::from_str(value),\n                ) {\n                    headers.insert(hname, hval);\n                }\n            }\n        }\n        http_client::inject_ua_header(&mut headers, opts.user_agent.as_deref());","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/platforms/direct_file.rs#L230-L266","documentation":"Thrown in DirectFileDownloader::download when reqwest::ClientBuilder::build() fails after applying proxy/cookie/timeout settings, mapped with anyhow! including the underlying reqwest error. It indicates the HTTP client could not be constructed at all — typically a TLS backend or proxy configuration problem, not a network failure of the request itself.","triggerScenarios":"Builder configured with an invalid or unreachable proxy (apply_global_proxy output), malformed cookie jar, or a reqwest build failure such as missing/unusable TLS backend (e.g. native-tls vs rustls mismatch) or invalid system proxy env vars.","commonSituations":"Users set HTTP_PROXY/HTTPS_PROXY env vars with invalid URLs; environments without CA certificates; builds with a TLS feature mismatch; corrupted cookie store configuration.","solutions":["Read the wrapped reqwest error in the message — it names the failing builder setting.","Check proxy env vars (HTTP_PROXY/HTTPS_PROXY/ALL_PROXY) and any global proxy config for malformed URLs; unset them to test.","Ensure the reqwest TLS feature is enabled and CA certificates are present in the environment.","Retry without the cookie jar / proxy overrides to isolate which builder option breaks."],"exampleFix":"// before\nlet client = builder.build().map_err(|e| anyhow!(\"Failed to build HTTP client: {}\", e))?;\n// after: fall back to a default client when custom builder options are the problem\nlet client = builder.build().unwrap_or_else(|e| {\n    tracing::warn!(\"client build failed ({}), using default\", e);\n    reqwest::Client::new()\n});","handlingStrategy":"try-catch","validationCode":"// check proxy env vars are well-formed before building\nfor v in [\"HTTP_PROXY\", \"HTTPS_PROXY\", \"ALL_PROXY\"] {\n    if let Ok(p) = std::env::var(v) {\n        url::Url::parse(&p).map_err(|_| anyhow!(\"{} is not a valid proxy URL: {}\", v, p))?;\n    }\n}","typeGuard":null,"tryCatchPattern":"match downloader.download(&info, &opts, tx).await {\n    Err(e) if e.to_string().contains(\"Failed to build HTTP client\") => {\n        eprintln!(\"check proxy settings / TLS config: {}\", e);\n        // retry with proxies disabled:\n        std::env::remove_var(\"HTTPS_PROXY\");\n        retry_download().await\n    }\n    other => other,\n}","preventionTips":["Keep proxy env vars as valid http(s):// URLs","Enable a reqwest TLS feature and ensure system CA certificates exist (common in slim Docker images)","Isolate builder options (proxy, cookie jar) so a failure can be attributed to one setting","Pin reqwest versions to avoid TLS feature regressions on upgrade"],"tags":["http-client","reqwest","proxy","tls"],"backgroundTag":"invalid-config-value","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}