{"record":{"id":"fb59867d00d0ed82","repo":"Kuberwastaken/claurst","slug":"failed-to-build-reqwest-client-fb5986","errorCode":null,"errorMessage":"failed to build reqwest client","messagePattern":"failed to build reqwest client","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src-rust/crates/api/src/providers/cohere.rs","lineNumber":47,"sourceCode":"use super::request_options::merge_root_options;\r\n\r\n// ---------------------------------------------------------------------------\r\n// CohereProvider\r\n// ---------------------------------------------------------------------------\r\n\r\npub struct CohereProvider {\r\n    id: ProviderId,\r\n    api_key: String,\r\n    http_client: reqwest::Client,\r\n}\r\n\r\nimpl CohereProvider {\r\n    /// Create a new CohereProvider with the given API key.\r\n    pub fn new(api_key: String) -> Self {\r\n        let http_client = reqwest::Client::builder()\r\n            .timeout(crate::request_timeout())\r\n            .build()\r\n            .expect(\"failed to build reqwest client\");\r\n\r\n        Self {\r\n            id: ProviderId::new(ProviderId::COHERE),\r\n            api_key,\r\n            http_client,\r\n        }\r\n    }\r\n\r\n    /// Construct from the `COHERE_API_KEY` environment variable.\r\n    /// Returns `None` if the variable is absent or empty.\r\n    pub fn from_env() -> Option<Self> {\r\n        std::env::var(\"COHERE_API_KEY\")\r\n            .ok()\r\n            .filter(|k| !k.is_empty())\r\n            .map(Self::new)\r\n    }\r\n\r\n    // -----------------------------------------------------------------------\r","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/api/src/providers/cohere.rs#L29-L65","documentation":"CohereProvider::new builds a reqwest::Client with the workspace request timeout and .expect()s the build result, panicking with 'failed to build reqwest client' on failure. Because reqwest client construction is nearly infallible, this panic signals an environment problem such as TLS backend initialization failure, not a bad API key.","triggerScenarios":"Constructing CohereProvider::new(api_key) where reqwest's client builder fails to build.","commonSituations":"Builds with no TLS backend enabled; musl/cross-compiled binaries without OpenSSL; slim container images missing TLS/CA libraries.","solutions":["Enable reqwest TLS (rustls-tls or default-tls) in Cargo features.","Check for feature conflicts with `cargo tree -i reqwest` and unify them.","For static builds, switch to rustls-tls to remove OpenSSL runtime deps.","Diagnose by constructing the reqwest client manually and printing the error.","Prefer a fallible constructor returning Result in your own provider code."],"exampleFix":"// before\nlet http_client = reqwest::Client::builder()\n    .timeout(crate::request_timeout())\n    .build()\n    .expect(\"failed to build reqwest client\");\n// after\nlet http_client = reqwest::Client::builder()\n    .timeout(crate::request_timeout())\n    .build()\n    .context(\"building Cohere HTTP client\")?;","handlingStrategy":"try-catch","validationCode":"reqwest::Client::builder().timeout(crate::request_timeout()).build()\n    .map_err(|e| anyhow!(\"reqwest TLS init failed: {e}\"))?;","typeGuard":null,"tryCatchPattern":"let http_client = reqwest::Client::builder()\n    .timeout(crate::request_timeout())\n    .build()\n    .map_err(|e| anyhow!(\"failed to build reqwest client: {e}\"))?;","preventionTips":["Enable rustls-tls (or default-tls) explicitly in Cargo.toml.","Verify TLS features with cargo tree -i reqwest in CI.","Install CA certificates in slim containers.","Validate provider construction during startup smoke tests."],"tags":["panic","http-client","tls","reqwest"],"backgroundTag":"internal-invariant-violation","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"}