getzola/zola · critical

reqwest client build

Error message

reqwest client build

What it means

LoadData::new unconditionally builds a reqwest HTTP client with a crate-specific user-agent and calls .expect("reqwest client build"), panicking if reqwest cannot construct its client. The builder only fails in rare cases such as TLS backend initialization failure. Since new() has no Result return, failure is fatal.

Source

Thrown at components/templates/src/functions/load_data.rs:233

}

/// A Tera function to load data from a file or from a URL
/// Currently the supported formats are json, toml, csv, yaml, bibtex and plain text
#[derive(Debug)]
pub struct LoadData {
    base_path: PathBuf,
    theme: Option<String>,
    client: Arc<Mutex<Client>>,
    result_cache: Arc<Mutex<HashMap<u64, Value>>>,
    output_path: PathBuf,
}
impl LoadData {
    pub fn new(base_path: PathBuf, theme: Option<String>, output_path: PathBuf) -> Self {
        let client = Arc::new(Mutex::new(
            Client::builder()
                .user_agent(concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")))
                .build()
                .expect("reqwest client build"),
        ));
        let result_cache = Arc::new(Mutex::new(HashMap::new()));
        Self { base_path, client, result_cache, theme, output_path }
    }
}

impl Default for LoadData {
    fn default() -> Self {
        let client = Arc::new(Mutex::new(
            Client::builder()
                .user_agent(concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")))
                .build()
                .expect("reqwest client build"),
        ));
        Self {
            base_path: PathBuf::new(),
            theme: None,
            client,

View on GitHub (pinned to 61d3082821)

Solutions

  1. Fix the system TLS stack: install/repair OpenSSL and CA certificates (e.g. apt install ca-certificates libssl-dev)
  2. Rebuild Zola with the rustls-tls feature of reqwest to avoid native OpenSSL dependency
  3. Refactor LoadData::new to return Result<Self, Error> and propagate Client::builder().build()? instead of expect

Example fix

// before
let client = Arc::new(Mutex::new(
    Client::builder()
        .user_agent(concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")))
        .build()
        .expect("reqwest client build"),
));
// after
let client = Arc::new(Mutex::new(
    Client::builder()
        .user_agent(concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")))
        .build()
        .map_err(|e| Error::message(format!("failed to build reqwest client: {}", e)))?,
));
Defensive patterns

Strategy: validation

Validate before calling

let client = reqwest::Client::builder()
    .user_agent(concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")))
    .build();
if let Err(e) = client {
    eprintln!("TLS/TCP stack unavailable: {}", e);
    std::process::exit(1);
}

Try / catch

// Rust: avoid expect; use Result propagation
Client::builder().build().map_err(|e| Error::message(format!("client build failed: {}", e)))?

Prevention

When it happens

Trigger: Calling LoadData::new when the reqwest TLS backend (native-tls/rustls) fails to initialize, e.g. broken OpenSSL installation or missing system certificates at runtime.

Common situations: Statically-linked or cross-compiled Zola binaries missing OpenSSL libs; CI containers without a CA certificate store; distro with incompatible libssl version.

Related errors


AI-assisted analysis of getzola/zola@61d3082821 (2026-09-03). Data as JSON: /api/errors/b8a38d2f6e3bff6e. Report an issue: GitHub.