Kuberwastaken/claurst · critical
failed to build reqwest client
Error message
failed to build reqwest client
What it means
CodexProvider::new builds a reqwest::Client with the workspace request timeout and .expect()s the result, panicking with 'failed to build reqwest client' if the client cannot be constructed. Client construction failing almost always means the TLS backend failed to initialize, so this panic points to a broken build/runtime environment.
Solutions
- Enable a TLS backend for reqwest (default-tls or rustls-tls) in the workspace features.
- Unify reqwest features with `cargo tree -i reqwest` to remove conflicts.
- Use rustls-tls for static/musl/cross builds to avoid OpenSSL issues.
- Build the client manually and log the underlying error to diagnose the environment.
- Change the constructor to return Result and propagate instead of expect.
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 Codex HTTP client")?; Defensive patterns
Strategy: try-catch
Validate before calling
reqwest::Client::builder().timeout(crate::request_timeout()).build()
.map_err(|e| anyhow!("reqwest TLS unavailable: {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 a single TLS backend for reqwest in workspace features.
- Run cargo tree -i reqwest to detect feature unification problems.
- Prefer rustls-tls for cross/musl builds.
- Construct providers early in startup so failures surface with context.
When it happens
Trigger: Constructing CodexProvider::new(tokens) where reqwest's builder().build() fails — effectively only TLS/backend initialization problems.
Common situations: Binaries built without a TLS feature; cross-compilation with missing OpenSSL; conflicting reqwest feature flags across the dependency graph.
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/c4add43f55d2d262.
Report an issue: GitHub.
Appendix: source
Thrown at src-rust/crates/api/src/providers/codex.rs:58
use crate::providers::copilot::CopilotProvider;
// ---------------------------------------------------------------------------
// CodexProvider
// ---------------------------------------------------------------------------
pub struct CodexProvider {
id: ProviderId,
http_client: reqwest::Client,
/// Mutable token cache: updated in-place when a refresh succeeds.
tokens: Arc<Mutex<CodexTokens>>,
}
impl CodexProvider {
pub fn new(tokens: CodexTokens) -> Self {
let http_client = reqwest::Client::builder()
.timeout(crate::request_timeout())
.build()
.expect("failed to build reqwest client");
Self {
id: ProviderId::new(ProviderId::CODEX),
http_client,
tokens: Arc::new(Mutex::new(tokens)),
}
}
/// Construct from stored tokens; returns `None` if no tokens are saved.
pub fn from_stored() -> Option<Self> {
let tokens = get_codex_tokens()?;
if tokens.access_token.is_empty() {
return None;
}
Some(Self::new(tokens))
}
// -----------------------------------------------------------------------View on GitHub (pinned to b0637c97ec)