Kuberwastaken/claurst · critical
failed to build reqwest client
Error message
failed to build reqwest client
What it means
CohereProvider::new builds a reqwest::Client with the workspace request timeout and .expect()s the build result, panicking with 'failed to build reqwest client' on failure. Because reqwest client construction is nearly infallible, this panic signals an environment problem such as TLS backend initialization failure, not a bad API key.
Solutions
- Enable reqwest TLS (rustls-tls or default-tls) in Cargo features.
- Check for feature conflicts with `cargo tree -i reqwest` and unify them.
- For static builds, switch to rustls-tls to remove OpenSSL runtime deps.
- Diagnose by constructing the reqwest client manually and printing the error.
- Prefer a fallible constructor returning Result in your own provider code.
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 Cohere 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()
.timeout(crate::request_timeout())
.build()
.map_err(|e| anyhow!("failed to build reqwest client: {e}"))?; Prevention
- Enable rustls-tls (or default-tls) explicitly in Cargo.toml.
- Verify TLS features with cargo tree -i reqwest in CI.
- Install CA certificates in slim containers.
- Validate provider construction during startup smoke tests.
When it happens
Trigger: Constructing CohereProvider::new(api_key) where reqwest's client builder fails to build.
Common situations: Builds with no TLS backend enabled; musl/cross-compiled binaries without OpenSSL; slim container images missing TLS/CA 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/fb59867d00d0ed82.
Report an issue: GitHub.
Appendix: source
Thrown at src-rust/crates/api/src/providers/cohere.rs:47
use super::request_options::merge_root_options;
// ---------------------------------------------------------------------------
// CohereProvider
// ---------------------------------------------------------------------------
pub struct CohereProvider {
id: ProviderId,
api_key: String,
http_client: reqwest::Client,
}
impl CohereProvider {
/// Create a new CohereProvider with the given API key.
pub fn new(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::COHERE),
api_key,
http_client,
}
}
/// Construct from the `COHERE_API_KEY` environment variable.
/// Returns `None` if the variable is absent or empty.
pub fn from_env() -> Option<Self> {
std::env::var("COHERE_API_KEY")
.ok()
.filter(|k| !k.is_empty())
.map(Self::new)
}
// -----------------------------------------------------------------------
View on GitHub (pinned to b0637c97ec)