{"record":{"id":"3d37a58bb9f803a0","repo":"Kuberwastaken/claurst","slug":"failed-to-build-reqwest-client-3d37a5","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/copilot.rs","lineNumber":56,"sourceCode":"};\nuse crate::providers::openai::OpenAiProvider;\n\n// ---------------------------------------------------------------------------\n// CopilotProvider\n// ---------------------------------------------------------------------------\n\npub struct CopilotProvider {\n    id: ProviderId,\n    token: String,\n    http_client: reqwest::Client,\n}\n\nimpl CopilotProvider {\n    pub fn new(token: String) -> 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::GITHUB_COPILOT),\n            token,\n            http_client,\n        }\n    }\n\n    pub fn from_env() -> Option<Self> {\n        std::env::var(\"GITHUB_TOKEN\").ok().map(Self::new)\n    }\n\n    fn base_url() -> &'static str {\n        \"https://api.githubcopilot.com\"\n    }\n\n    fn block_has_image(block: &ContentBlock) -> bool {\n        match block {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/api/src/providers/copilot.rs#L38-L74","documentation":"CopilotProvider::new builds a reqwest::Client with the workspace request timeout and .expect()s the result, panicking with 'failed to build reqwest client' if construction fails. This is effectively an internal invariant: reqwest client construction only fails on environment-level problems like a missing TLS backend.","triggerScenarios":"Constructing CopilotProvider::new(token) in a binary where reqwest's builder fails — TLS backend init failure.","commonSituations":"No TLS feature enabled in the build graph; cross-compiled/musl binaries missing OpenSSL; container images stripped of CA/TLS libs.","solutions":["Enable a reqwest TLS backend (rustls-tls recommended for portability).","Resolve reqwest feature conflicts via `cargo tree -i reqwest`.","For static targets, use rustls-tls instead of native-tls.","Rebuild the client manually and inspect the reqwest error to find the root cause.","Convert the constructor to return Result and propagate the error."],"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 Copilot 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 exactly one TLS backend in the dependency graph.","Prefer rustls-tls for portable/static binaries.","Add ca-certificates to minimal container images.","Catch construction failure at startup rather than at first Copilot request."],"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"}