{"record":{"id":"f6c1a58b5f12fdaa","repo":"tonhowtf/omniget","slug":"failed-to-build-http-client-mod","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-tauri/src/platforms/direct_file/mod.rs","lineNumber":132,"sourceCode":"        let mut builder = http_client::apply_global_proxy(reqwest::Client::builder())\n            .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 = 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":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/src/platforms/direct_file/mod.rs#L114-L150","documentation":"The reqwest `ClientBuilder::build()` call failed while constructing the HTTP client used for the direct file download (headers, cookies, redirects already configured). This is a client-construction failure, not a request failure — typically invalid TLS backend state or bad builder configuration.","triggerScenarios":"Calling `download` when the reqwest builder cannot be finalized — e.g. TLS backend initialization failure (rustls/native-tls issues), a bad `cookie_provider` jar, or conflicting builder options.","commonSituations":"Missing/incorrectly linked TLS backend (no `default-tls`/`rustls-tls` feature enabled in a static build), a custom cookie jar whose Arc/RwLock is poisoned, or platform-specific crypto issues on stripped-down Docker images.","solutions":["Read the wrapped error message in `Failed to build HTTP client: {}` to identify the root cause (usually TLS).","Enable a TLS feature on reqwest in Cargo.toml, e.g. `reqwest = { version = \"...\", features = [\"rustls-tls\"] }`.","If using a custom cookie jar, verify it is constructed correctly and not poisoned before passing to `cookie_provider`.","Check the deployment image includes the CA/OpenSSL runtime files needed by the chosen TLS backend."],"exampleFix":"// before (Cargo.toml)\nreqwest = \"0.12\"\n// after (Cargo.toml)\nreqwest = { version = \"0.12\", features = [\"rustls-tls\", \"cookies\"] }","handlingStrategy":"try-catch","validationCode":"// Rust, sanity-check TLS backend support at startup\nlet probe = reqwest::Client::builder().timeout(std::time::Duration::from_secs(10)).build();\nif probe.is_err() {\n    eprintln!(\"reqwest client cannot be built — check TLS features/features in Cargo.toml\");\n}","typeGuard":null,"tryCatchPattern":"// Rust\nmatch build_client(jar).await {\n    Ok(client) => client,\n    Err(e) => {\n        log::error!(\"HTTP client build failed: {e:#}; verify reqwest TLS/cookies features\");\n        return Err(anyhow!(\"HTTP client unavailable: {e}\"));\n    }\n}","preventionTips":["Always enable a TLS feature (rustls-tls or native-tls) for reqwest in Cargo.toml.","Probe client construction in a startup health check rather than at download time.","Keep cookie jar construction simple and tested; avoid reusing possibly-poisoned shared jars."],"tags":["http","reqwest","tls","client-init"],"backgroundTag":"http-request-failed","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"}