{"record":{"id":"4ca6bda5d1b6ca0b","repo":"tonhowtf/omniget","slug":"downloaded-pdfium-archive-is-too-small-bytes-likely-an-error","errorCode":null,"errorMessage":"Downloaded pdfium archive is too small ({} bytes) — likely an error page","messagePattern":"Downloaded pdfium archive is too small \\((.+?) bytes\\) — likely an error page","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/pdfium.rs","lineNumber":188,"sourceCode":"    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>> {\n            extract_pdfium_archive(&bytes, &target_path_clone, &target_dir_clone, &lib_name)\n        })\n        .await\n        .map_err(|e| anyhow!(\"spawn_blocking failed: {}\", e))??;\n\n    if let Some(version_marker) = pdfium_version_marker_path() {\n        let base = extracted_version.unwrap_or_else(|| \"latest\".to_string());\n        let value = format!(\"{} ({})\", base, archive_name);","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/pdfium.rs#L170-L206","documentation":"After a successful HTTP status, ensure_pdfium_with_variant() sanity-checks the downloaded byte count: archives smaller than 100,000 bytes are rejected because real pdfium archives are always far larger — a small payload is almost certainly an HTML error page or a stub response that slipped through with a 200 status.","triggerScenarios":"The server returns HTTP 200 but the body is tiny: a captive-portal/proxy HTML page, an API rate-limit JSON message, or a truncated download.","commonSituations":"Wi-Fi captive portals intercepting the first request; anti-bot/CDN challenge pages served with 200; misconfigured corporate proxies returning an error page; extremely truncated transfer.","solutions":["Inspect what the endpoint actually returns (curl the URL) — usually an HTML error/challenge page","Bypass or correctly configure the proxy/captive portal and retry","Use the global proxy configuration (apply_global_proxy) to point at a working proxy","Install pdfium from a local archive via set_pdfium_from_path instead of downloading"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let resp = client.get(&probe_url).send().await?;\nlet ct = resp.headers().get(reqwest::header::CONTENT_TYPE);\nif let Some(ct) = ct {\n    if ct.to_str().unwrap_or(\"\").starts_with(\"text/html\") {\n        eprintln!(\"endpoint returned HTML — captive portal or error page\");\n    }\n}","typeGuard":null,"tryCatchPattern":"match ensure_pdfium().await {\n    Err(e) if e.to_string().contains(\"too small\") => {\n        // network intercepted: switch network/proxy, then retry\n    }\n    other => other.map(|_| ()),\n}","preventionTips":["Check Content-Type before trusting a 200 response from download endpoints","Detect and handle captive portals before first-run downloads","Fall back to set_pdfium_from_path with a bundled archive when downloads look intercepted"],"tags":["network","download","pdfium","validation"],"backgroundTag":"unexpected-response-shape","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"}