{"record":{"id":"c4add43f55d2d262","repo":"Kuberwastaken/claurst","slug":"failed-to-build-reqwest-client-c4add4","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/codex.rs","lineNumber":58,"sourceCode":"use crate::providers::copilot::CopilotProvider;\n\n// ---------------------------------------------------------------------------\n// CodexProvider\n// ---------------------------------------------------------------------------\n\npub struct CodexProvider {\n    id: ProviderId,\n    http_client: reqwest::Client,\n    /// Mutable token cache: updated in-place when a refresh succeeds.\n    tokens: Arc<Mutex<CodexTokens>>,\n}\n\nimpl CodexProvider {\n    pub fn new(tokens: CodexTokens) -> Self {\n        let http_client = reqwest::Client::builder()\n            .timeout(crate::request_timeout())\n            .build()\n            .expect(\"failed to build reqwest client\");\n\n        Self {\n            id: ProviderId::new(ProviderId::CODEX),\n            http_client,\n            tokens: Arc::new(Mutex::new(tokens)),\n        }\n    }\n\n    /// Construct from stored tokens; returns `None` if no tokens are saved.\n    pub fn from_stored() -> Option<Self> {\n        let tokens = get_codex_tokens()?;\n        if tokens.access_token.is_empty() {\n            return None;\n        }\n        Some(Self::new(tokens))\n    }\n\n    // -----------------------------------------------------------------------","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/api/src/providers/codex.rs#L40-L76","documentation":"CodexProvider::new builds a reqwest::Client with the workspace request timeout and .expect()s the result, panicking with 'failed to build reqwest client' if the client cannot be constructed. Client construction failing almost always means the TLS backend failed to initialize, so this panic points to a broken build/runtime environment.","triggerScenarios":"Constructing CodexProvider::new(tokens) where reqwest's builder().build() fails — effectively only TLS/backend initialization problems.","commonSituations":"Binaries built without a TLS feature; cross-compilation with missing OpenSSL; conflicting reqwest feature flags across the dependency graph.","solutions":["Enable a TLS backend for reqwest (default-tls or rustls-tls) in the workspace features.","Unify reqwest features with `cargo tree -i reqwest` to remove conflicts.","Use rustls-tls for static/musl/cross builds to avoid OpenSSL issues.","Build the client manually and log the underlying error to diagnose the environment.","Change the constructor to return Result and propagate instead of expect."],"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 Codex HTTP client\")?;","handlingStrategy":"try-catch","validationCode":"reqwest::Client::builder().timeout(crate::request_timeout()).build()\n    .map_err(|e| anyhow!(\"reqwest TLS unavailable: {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 a single TLS backend for reqwest in workspace features.","Run cargo tree -i reqwest to detect feature unification problems.","Prefer rustls-tls for cross/musl builds.","Construct providers early in startup so failures surface with context."],"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"}