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

  1. Fix the build so reqwest has a working TLS backend (enable reqwest default-tls or rustls-tls).
  2. Run `cargo tree -i reqwest` to check for conflicting TLS feature selections and unify them via a workspace feature.
  3. For static/musl targets, prefer rustls-tls to avoid OpenSSL linking issues.
  4. If the panic persists, construct the reqwest client yourself and inspect the returned error for the root cause.
  5. 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

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


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)