Kuberwastaken/claurst · critical

MinimaxProvider: failed to build HTTP client

Error message

MinimaxProvider: failed to build HTTP client

What it means

MinimaxProvider::new builds a reqwest Client with the prepared default headers and request timeout, and .expect()s the build result, panicking with 'MinimaxProvider: failed to build HTTP client'. As with other reqwest build failures, this practically only happens when the TLS backend cannot initialize.

Solutions

  1. Enable a reqwest TLS backend (rustls-tls or default-tls) in Cargo features.
  2. Unify reqwest features with `cargo tree -i reqwest` to eliminate conflicts.
  3. Use rustls-tls for static/cross builds; install ca-certificates in slim containers.
  4. Reproduce by building a bare reqwest client and logging the returned error.
  5. Replace the expect with a fallible constructor returning Result.

Example fix

// before
.expect("MinimaxProvider: failed to build HTTP client");
// after
.build()
.context("building Minimax HTTP client")?;
Defensive patterns

Strategy: try-catch

Validate before calling

reqwest::Client::builder().timeout(crate::request_timeout()).build()
    .map_err(|e| anyhow!("reqwest/TLS init failed: {e}"))?;

Try / catch

let http_client = reqwest::Client::builder()
    .default_headers(headers)
    .timeout(crate::request_timeout())
    .build()
    .map_err(|e| anyhow!("failed to build Minimax HTTP client: {e}"))?;

Prevention

When it happens

Trigger: Constructing MinimaxProvider::new(api_key) where reqwest's Client::builder().build() fails after the X-Api-Key default header was installed.

Common situations: Builds missing a TLS backend; musl/cross-compiled binaries without OpenSSL; minimal container images lacking CA certificates; conflicting reqwest feature flags.

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/d0b1561406510bb4. Report an issue: GitHub.

Appendix: source

Thrown at src-rust/crates/api/src/providers/minimax.rs:42

pub struct MinimaxProvider {
    http_client: Client,
    api_key: String,
    api_base: String,
    service_tier: Option<String>,
    id: ProviderId,
}

impl MinimaxProvider {
    pub fn new(api_key: String) -> Self {
        let api_base = std::env::var("MINIMAX_BASE_URL")
            .unwrap_or_else(|_| claurst_core::constants::MINIMAX_ANTHROPIC_API_BASE.to_string());
        let mut headers = header::HeaderMap::new();
        headers.insert("X-Api-Key", header::HeaderValue::from_str(&api_key).expect("unable to parse api key for http header"));
        let http_client = Client::builder()
            .default_headers(headers)
            .timeout(crate::request_timeout())
            .build()
            .expect("MinimaxProvider: failed to build HTTP client");

        Self {
            http_client,
            api_key,
            api_base,
            service_tier: None,
            id: ProviderId::new(ProviderId::MINIMAX),
        }
    }

    pub fn with_base_url(mut self, api_base: impl Into<String>) -> Self {
        self.api_base = api_base.into();
        self
    }

    pub fn with_service_tier(mut self, service_tier: impl Into<String>) -> Self {
        self.service_tier = Some(service_tier.into());
        self

View on GitHub (pinned to b0637c97ec)