{"record":{"id":"b8a38d2f6e3bff6e","repo":"getzola/zola","slug":"reqwest-client-build-b8a38d","errorCode":null,"errorMessage":"reqwest client build","messagePattern":"reqwest client build","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"components/templates/src/functions/load_data.rs","lineNumber":233,"sourceCode":"}\n\n/// A Tera function to load data from a file or from a URL\n/// Currently the supported formats are json, toml, csv, yaml, bibtex and plain text\n#[derive(Debug)]\npub struct LoadData {\n    base_path: PathBuf,\n    theme: Option<String>,\n    client: Arc<Mutex<Client>>,\n    result_cache: Arc<Mutex<HashMap<u64, Value>>>,\n    output_path: PathBuf,\n}\nimpl LoadData {\n    pub fn new(base_path: PathBuf, theme: Option<String>, output_path: PathBuf) -> Self {\n        let client = Arc::new(Mutex::new(\n            Client::builder()\n                .user_agent(concat!(env!(\"CARGO_PKG_NAME\"), \"/\", env!(\"CARGO_PKG_VERSION\")))\n                .build()\n                .expect(\"reqwest client build\"),\n        ));\n        let result_cache = Arc::new(Mutex::new(HashMap::new()));\n        Self { base_path, client, result_cache, theme, output_path }\n    }\n}\n\nimpl Default for LoadData {\n    fn default() -> Self {\n        let client = Arc::new(Mutex::new(\n            Client::builder()\n                .user_agent(concat!(env!(\"CARGO_PKG_NAME\"), \"/\", env!(\"CARGO_PKG_VERSION\")))\n                .build()\n                .expect(\"reqwest client build\"),\n        ));\n        Self {\n            base_path: PathBuf::new(),\n            theme: None,\n            client,","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/getzola/zola/blob/61d30828217957120309db657950224edf9707e2/components/templates/src/functions/load_data.rs#L215-L251","documentation":"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.","triggerScenarios":"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.","commonSituations":"Statically-linked or cross-compiled Zola binaries missing OpenSSL libs; CI containers without a CA certificate store; distro with incompatible libssl version.","solutions":["Fix the system TLS stack: install/repair OpenSSL and CA certificates (e.g. apt install ca-certificates libssl-dev)","Rebuild Zola with the rustls-tls feature of reqwest to avoid native OpenSSL dependency","Refactor LoadData::new to return Result<Self, Error> and propagate Client::builder().build()? instead of expect"],"exampleFix":"// before\nlet client = Arc::new(Mutex::new(\n    Client::builder()\n        .user_agent(concat!(env!(\"CARGO_PKG_NAME\"), \"/\", env!(\"CARGO_PKG_VERSION\")))\n        .build()\n        .expect(\"reqwest client build\"),\n));\n// after\nlet client = Arc::new(Mutex::new(\n    Client::builder()\n        .user_agent(concat!(env!(\"CARGO_PKG_NAME\"), \"/\", env!(\"CARGO_PKG_VERSION\")))\n        .build()\n        .map_err(|e| Error::message(format!(\"failed to build reqwest client: {}\", e)))?,\n));","handlingStrategy":"validation","validationCode":"let client = reqwest::Client::builder()\n    .user_agent(concat!(env!(\"CARGO_PKG_NAME\"), \"/\", env!(\"CARGO_PKG_VERSION\")))\n    .build();\nif let Err(e) = client {\n    eprintln!(\"TLS/TCP stack unavailable: {}\", e);\n    std::process::exit(1);\n}","typeGuard":null,"tryCatchPattern":"// Rust: avoid expect; use Result propagation\nClient::builder().build().map_err(|e| Error::message(format!(\"client build failed: {}\", e)))?","preventionTips":["Build with rustls-tls to remove native OpenSSL runtime dependency","Ensure ca-certificates is installed in container/CI images","Smoke-test client construction at binary startup, not on first use"],"tags":["rust","reqwest","panic","tls","http-client"],"backgroundTag":"reqwest-client-build-failure","analyzedSha":"61d30828217957120309db657950224edf9707e2","analyzedAt":"2026-09-03T14:39:09.727Z","contentChangedAt":"2026-09-03T14:39:09.727Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}