{"record":{"id":"9d8eb37aa3201bb5","repo":"tonhowtf/omniget","slug":"failed-to-download-pdfium-from-http","errorCode":null,"errorMessage":"Failed to download pdfium from {}: HTTP {}","messagePattern":"Failed to download pdfium from (.+?): HTTP (.+?)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/pdfium.rs","lineNumber":180,"sourceCode":"    let target_dir =\n        pdfium_target_dir().ok_or_else(|| anyhow!(\"could not determine app data dir\"))?;\n    std::fs::create_dir_all(&target_dir)\n        .with_context(|| format!(\"creating pdfium target dir {}\", target_dir.display()))?;\n\n    let archive_name = archive_name_for_variant(variant.as_deref());\n    let url = format!(\"{}/{}\", PDFIUM_DOWNLOAD_BASE, archive_name);\n    let lib_filename = pdfium_lib_filename();\n    let target_path = target_dir.join(lib_filename);\n\n    tracing::info!(\"Downloading pdfium from {}\", url);\n\n    let client = crate::core::http_client::apply_global_proxy(reqwest::Client::builder())\n        .timeout(std::time::Duration::from_secs(600))\n        .build()?;\n\n    let response = client.get(&url).send().await?;\n    if !response.status().is_success() {\n        return Err(anyhow!(\n            \"Failed to download pdfium from {}: HTTP {}\",\n            url,\n            response.status()\n        ));\n    }\n    let bytes = response.bytes().await?.to_vec();\n    if bytes.len() < 100_000 {\n        return Err(anyhow!(\n            \"Downloaded pdfium archive is too small ({} bytes) — likely an error page\",\n            bytes.len()\n        ));\n    }\n\n    let target_path_clone = target_path.clone();\n    let target_dir_clone = target_dir.clone();\n    let lib_name = lib_filename.to_string();\n    let extracted_version =\n        tokio::task::spawn_blocking(move || -> anyhow::Result<Option<String>> {","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/pdfium.rs#L162-L198","documentation":"When downloading the pdfium archive, ensure_pdfium_with_variant() checks the HTTP status of the response and throws this error for any non-success status. The message includes the full source URL and the numeric HTTP status, so it distinguishes 404 (bad base URL/variant), 403 (rate-limit/blocked), 5xx (server outage), etc.","triggerScenarios":"The GET request to PDFIUM_DOWNLOAD_BASE + archive_name returns a non-2xx status: wrong or renamed archive variant, outdated download base URL, offline proxy returning errors, or GitHub/bento release assets moved.","commonSituations":"New pdfium release renamed the asset so the constructed archive_name 404s; corporate proxy blocks bslashdev/github downloads; transient 502/503 from the CDN.","solutions":["Read the HTTP status in the message: 404 means fix the URL/archive variant; 403 means auth/proxy issue; 5xx means retry later","Verify PDFIUM_DOWNLOAD_BASE still points to valid release assets and that the variant name maps to an existing archive","Retry after checking network/proxy; the request has a 600s timeout so failures are genuine server responses","Pin a known-good pdfium archive name or install from a local file with set_pdfium_from_path"],"exampleFix":"// retry with a fallback variant on 404\nmatch ensure_pdfium_with_variant(Some(variant)).await {\n    Err(e) if e.to_string().contains(\"HTTP 404\") => ensure_pdfium_with_variant(None).await,\n    other => other,\n}","handlingStrategy":"retry","validationCode":"let head = client.head(&url).send().await?;\nif !head.status().is_success() {\n    eprintln!(\"pdfium URL not reachable: {}\", head.status());\n}","typeGuard":null,"tryCatchPattern":"match ensure_pdfium().await {\n    Err(e) if e.to_string().contains(\"Failed to download pdfium\") => {\n        // inspect HTTP status in message; retry with backoff or pin another release\n    }\n    other => other.map(|_| ()),\n}","preventionTips":["Retry transient 5xx with exponential backoff; don't retry 4xx blindly","Pin a known-good pdfium release/variant instead of floating 'latest'","Configure the global proxy so downloads work behind corporate networks"],"tags":["network","http","pdfium","download"],"backgroundTag":"http-error-response","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}