Kuberwastaken/claurst · critical
failed to build reqwest client
Error message
failed to build reqwest client
What it means
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).
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>.
Example fix
// before
let http_client = reqwest::Client::builder()
.timeout(crate::request_timeout())
.build()
.expect("failed to build reqwest client");
// after
let http_client = reqwest::Client::builder()
.timeout(crate::request_timeout())
.build()
.context("building Azure HTTP client")?; Defensive patterns
Strategy: try-catch
Validate before calling
// verify at startup that a client can be built before constructing providers
reqwest::Client::builder().timeout(crate::request_timeout()).build()
.map_err(|e| anyhow!("reqwest/TLS unavailable in this environment: {e}"))?; Try / catch
let http_client = reqwest::Client::builder()
.timeout(crate::request_timeout())
.build()
.map_err(|e| anyhow!("failed to build reqwest client: {e}"))?; Prevention
- 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.
When it happens
Trigger: Constructing AzureProvider::new(resource_name, api_key) in a binary built without a usable TLS backend, or where the TLS library fails to initialize.
Common situations: Cross-compiled or musl builds missing OpenSSL; conflicting reqwest TLS feature flags in the dependency graph; stripped-down container images without CA/TLS libraries.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- failed to build reqwest client
- failed to build reqwest client
- failed to build reqwest client
- failed to build reqwest client
- MinimaxProvider: failed to build HTTP client
AI-assisted analysis of Kuberwastaken/claurst@b0637c97ec (2026-09-10).
Data as JSON: /api/errors/3c2f9851157714e5.
Report an issue: GitHub.
Appendix: source
Thrown at src-rust/crates/api/src/providers/azure.rs:48
// ---------------------------------------------------------------------------
// AzureProvider
// ---------------------------------------------------------------------------
pub struct AzureProvider {
id: ProviderId,
resource_name: String,
api_key: String,
api_version: String,
http_client: reqwest::Client,
}
impl AzureProvider {
pub fn new(resource_name: String, api_key: String) -> Self {
let http_client = reqwest::Client::builder()
.timeout(crate::request_timeout())
.build()
.expect("failed to build reqwest client");
Self {
id: ProviderId::new(ProviderId::AZURE),
resource_name,
api_key,
api_version: "2024-08-01-preview".to_string(),
http_client,
}
}
pub fn with_api_version(mut self, version: String) -> Self {
self.api_version = version;
self
}
pub fn from_env() -> Option<Self> {
let key = std::env::var("AZURE_API_KEY").ok()?;
let resource = std::env::var("AZURE_RESOURCE_NAME").ok()?;
View on GitHub (pinned to b0637c97ec)