{"record":{"id":"3566cb61ee3f3e25","repo":"tinyhumansai/openhuman","slug":"failed-to-build-shared-searxng-http-client","errorCode":null,"errorMessage":"failed to build shared SearXNG HTTP client","messagePattern":"failed to build shared SearXNG HTTP client","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/openhuman/search/tools/searxng.rs","lineNumber":29,"sourceCode":"use serde::{Deserialize, Serialize};\nuse serde_json::json;\nuse std::sync::OnceLock;\nuse std::time::Duration;\n\nconst DEFAULT_SOURCE: &str = \"searxng\";\n/// Maximum number of SearXNG results accepted by the public tool surface.\npub const MAX_RESULTS: usize = 50;\n\nstatic SHARED_HTTP_CLIENT: OnceLock<reqwest::Client> = OnceLock::new();\n\nfn shared_http_client() -> reqwest::Client {\n    SHARED_HTTP_CLIENT\n        .get_or_init(|| {\n            tracing::debug!(\"[searxng] initializing shared HTTP client\");\n            // Platform-appropriate TLS backend — see [`crate::openhuman::util::tls`].\n            crate::openhuman::util::tls::tls_client_builder()\n                .build()\n                .expect(\"failed to build shared SearXNG HTTP client\")\n        })\n        .clone()\n}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\n/// Search arguments accepted by the SearXNG tool.\npub struct SearxngSearchArgs {\n    /// Search query sent as SearXNG's `q` parameter.\n    pub query: String,\n    /// Optional SearXNG categories. `web` is normalized to `general`.\n    pub categories: Vec<String>,\n    /// Optional language code. Falls back to the configured default when absent.\n    pub language: Option<String>,\n    /// Optional per-call result limit, clamped to the supported maximum.\n    pub max_results: Option<usize>,\n}\n\n#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/search/tools/searxng.rs#L11-L47","documentation":"Panic payload inside shared_http_client(): the SearXNG tool lazily builds one process-wide reqwest client in a OnceLock (platform TLS backend + timeouts). A build failure here is environment-level (TLS/proxy) and, because it happens inside get_or_init on first use (from new()), it poisons the OnceLock and permanently disables SearXNG search for the process.","triggerScenarios":"Thrown at src/openhuman/search/tools/searxng.rs:29 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check TLS backend availability and proxy configuration on the host","Restart the process after fixing the environment — the OnceLock stays poisoned for the process lifetime","Avoid .expect inside get_or_init; store a Result so later callers can retry or degrade"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}