{"record":{"id":"a89fff221cdc6c6b","repo":"sigoden/aichat","slug":"err-a89fff","errorCode":null,"errorMessage":"{err}","messagePattern":"\\{err\\}","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/utils/request.rs","lineNumber":63,"sourceCode":"        (\n            Regex::new(r\"github.com/([^/]+)/([^/]+)/wiki\").unwrap(),\n            CrawlOptions {\n                exclude: vec![\"_history\".into()],\n                extract: Some(\"#wiki-body\".into()),\n                ..Default::default()\n            },\n        ),\n    ]\n});\n\nstatic EXTENSION_RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r\"\\.[^.]+$\").unwrap());\nstatic GITHUB_REPO_RE: LazyLock<Regex> =\n    LazyLock::new(|| Regex::new(r\"^https://github\\.com/([^/]+)/([^/]+)/tree/([^/]+)\").unwrap());\n\npub async fn fetch(url: &str) -> Result<String> {\n    let client = match *CLIENT {\n        Ok(ref client) => client,\n        Err(ref err) => bail!(\"{err}\"),\n    };\n    let res = client.get(url).send().await?;\n    let output = res.text().await?;\n    Ok(output)\n}\n\npub async fn fetch_with_loaders(\n    loaders: &HashMap<String, String>,\n    path: &str,\n    allow_media: bool,\n) -> Result<(String, String)> {\n    if let Some(loader_command) = loaders.get(URL_LOADER) {\n        let contents = run_loader_command(path, URL_LOADER, loader_command)?;\n        return Ok((contents, DEFAULT_EXTENSION.into()));\n    }\n    let client = match *CLIENT {\n        Ok(ref client) => client,\n        Err(ref err) => bail!(\"{err}\"),","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/utils/request.rs#L45-L81","documentation":"fetch() returns the stored CLIENT construction error when the global HTTP client failed to initialize. The bail just re-emits that stored error, so the root cause is the client's lazy initialization failure (e.g. invalid proxy settings).","triggerScenarios":"Calling sync_models (or any code path through fetch) when reqwest::Client could not be built at startup — commonly due to invalid HTTP(S)_PROXY/ALL_PROXY env values or TLS backend issues.","commonSituations":"Corporate proxy env vars set to malformed URLs; bad CA cert configuration; TLS runtime not available in the build.","solutions":["Read the underlying message; fix the proxy URL in http_proxy/https_proxy/all_proxy","Unset invalid proxy env vars and retry","Ensure the binary was built with TLS support and valid CA certificates are installed","Update the app in case of a known client-init bug"],"exampleFix":"// before: invalid proxy\nexport https_proxy=\"127.0.0.1:7890\"  // missing scheme\n// after\nexport https_proxy=\"http://127.0.0.1:7890\"","handlingStrategy":"try-catch","validationCode":"function validateProxyEnv() {\n  for (const k of ['http_proxy', 'https_proxy', 'all_proxy']) {\n    const v = process.env[k];\n    if (v && !/^https?:\\/\\/|^socks5:\\/\\//.test(v)) {\n      throw new Error(`${k} must be a full URL, got: ${v}`);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const models = await syncModels();\n} catch (e) {\n  // likely client init failure: check proxy env / TLS setup\n  console.error('http client unavailable:', e.message);\n}","preventionTips":["Keep proxy env vars as full URLs with scheme","Verify CA certificates on the host","Smoke-test network calls at startup"],"tags":["http","client-init","proxy","network"],"backgroundTag":"module-init-failed","analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}