{"record":{"id":"3c2f9851157714e5","repo":"Kuberwastaken/claurst","slug":"failed-to-build-reqwest-client","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/azure.rs","lineNumber":48,"sourceCode":"\r\n// ---------------------------------------------------------------------------\r\n// AzureProvider\r\n// ---------------------------------------------------------------------------\r\n\r\npub struct AzureProvider {\r\n    id: ProviderId,\r\n    resource_name: String,\r\n    api_key: String,\r\n    api_version: String,\r\n    http_client: reqwest::Client,\r\n}\r\n\r\nimpl AzureProvider {\r\n    pub fn new(resource_name: String, 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::AZURE),\r\n            resource_name,\r\n            api_key,\r\n            api_version: \"2024-08-01-preview\".to_string(),\r\n            http_client,\r\n        }\r\n    }\r\n\r\n    pub fn with_api_version(mut self, version: String) -> Self {\r\n        self.api_version = version;\r\n        self\r\n    }\r\n\r\n    pub fn from_env() -> Option<Self> {\r\n        let key = std::env::var(\"AZURE_API_KEY\").ok()?;\r\n        let resource = std::env::var(\"AZURE_RESOURCE_NAME\").ok()?;\r","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/api/src/providers/azure.rs#L30-L66","documentation":"AzureProvider::new builds a reqwest::Client with the configured request timeout and .expect()s the build result, panicking with 'failed to build reqwest client' if construction fails. reqwest client construction is almost always infallible, so this panic indicates a broken environment (typically TLS backend failure).","triggerScenarios":"Constructing AzureProvider::new(resource_name, api_key) in a binary built without a usable TLS backend, or where the TLS library fails to initialize.","commonSituations":"Cross-compiled or musl builds missing OpenSSL; conflicting reqwest TLS feature flags in the dependency graph; stripped-down container images without CA/TLS libraries.","solutions":["Fix the build so reqwest has a working TLS backend (enable reqwest default-tls or rustls-tls).","Run `cargo tree -i reqwest` to check for conflicting TLS feature selections and unify them via a workspace feature.","For static/musl targets, prefer rustls-tls to avoid OpenSSL linking issues.","If the panic persists, construct the reqwest client yourself and inspect the returned error for the root cause.","If constructing in code you own, replace the expect with a fallible constructor returning anyhow::Result<Self>."],"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 Azure HTTP client\")?;","handlingStrategy":"try-catch","validationCode":"// verify at startup that a client can be built before constructing providers\nreqwest::Client::builder().timeout(crate::request_timeout()).build()\n    .map_err(|e| anyhow!(\"reqwest/TLS unavailable in this environment: {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 (rustls-tls preferred) in Cargo features.","Run cargo tree -i reqwest in CI to catch feature conflicts.","Prefer rustls for musl/static/cross-compiled targets.","Install ca-certificates in minimal container images.","Fail fast at startup with a clear message if client construction fails."],"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"}