{"record":{"id":"1c1670f8d84e400e","repo":"Zackriya-Solutions/meetily","slug":"stored-bytes-expected-exactly-bytes","errorCode":null,"errorMessage":"{} stored {} bytes, expected exactly {} bytes","messagePattern":"(.+?) stored (.+?) bytes, expected exactly (.+?) bytes","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/parakeet_engine/parakeet_engine.rs","lineNumber":1105,"sourceCode":"                    bytes_since_report = 0;\n                }\n            }\n\n            writer\n                .flush()\n                .await\n                .map_err(|error| anyhow!(\"Failed to flush {}: {}\", artifact.filename, error))?;\n            drop(writer);\n\n            if active_download.cancellation.is_cancelled() {\n                return Err(DownloadCancelled.into());\n            }\n            let stored_bytes = fs::metadata(&file_path)\n                .await\n                .map_err(|error| anyhow!(\"Failed to read {} after download: {}\", artifact.filename, error))?\n                .len();\n            if stored_bytes != artifact.exact_bytes {\n                return Err(anyhow!(\n                    \"{} stored {} bytes, expected exactly {} bytes\",\n                    artifact.filename,\n                    stored_bytes,\n                    artifact.exact_bytes\n                ));\n            }\n        }\n\n        if confirmed_bytes != total_bytes {\n            return Err(anyhow!(\n                \"Download confirmed {} bytes, expected {} bytes\",\n                confirmed_bytes,\n                total_bytes\n            ));\n        }\n        let elapsed = download_started.elapsed().as_secs_f64();\n        let speed_mbps = if elapsed > 0.0 {\n            streamed_bytes as f64 / (1024.0 * 1024.0) / elapsed","sourceCodeStart":1087,"sourceCodeEnd":1123,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/a2cb62e827da7ef59f65064c97233efb2313878e/frontend/src-tauri/src/parakeet_engine/parakeet_engine.rs#L1087-L1123","documentation":"Per-artifact byte-exact verification. Parakeet artifacts declare an exact_bytes field; after download the engine compares the on-disk size against it and rejects any mismatch. This catches truncated, padded, or corrupted downloads (e.g., HTML error pages written to the file) before the model is registered.","triggerScenarios":"fs::metadata(&file_path).len() != artifact.exact_bytes after the artifact download future resolved successfully — i.e., the transport reported success but the stored file differs in size from the manifest's declared exact size.","commonSituations":"Proxy or captive portal injecting an HTML login/error page into the download; interrupted-but-resumed download producing a truncated file; CDN serving a stale/partial object; URL changed on the server so the manifest's exact_bytes no longer matches the actual file version.","solutions":["Delete the downloaded artifact and retry the download to rule out a transient network/proxy corruption.","Verify network path: disable proxy/VPN or check captive portal status, then retry.","Compare the served file's actual size against the manifest (curl -sI <url> | grep Content-Length) to see if the server changed the file.","Update the app or model manifest so artifact.exact_bytes matches the current server-side file."],"exampleFix":"// before\nif stored_bytes != artifact.exact_bytes {\n    return Err(anyhow!(\"{} stored {} bytes, expected exactly {} bytes\", artifact.filename, stored_bytes, artifact.exact_bytes));\n}\n// after (auto-retry download once on size mismatch)\nif stored_bytes != artifact.exact_bytes {\n    fs::remove_file(&file_path).await.ok();\n    download_once(&artifact, &file_path).await?;\n    let stored_bytes = fs::metadata(&file_path).await?.len();\n    if stored_bytes != artifact.exact_bytes {\n        return Err(anyhow!(\"{} stored {} bytes, expected exactly {} bytes\", artifact.filename, stored_bytes, artifact.exact_bytes));\n    }\n}","handlingStrategy":"validation","validationCode":"// TypeScript/Rust caller side: verify expected size before accepting a downloaded file\nconst stat = await stat(filePath);\nif (stat.size !== artifact.exact_bytes) {\n  throw new Error(`size mismatch: got ${stat.size}, want ${artifact.exact_bytes}`);\n}","typeGuard":"// Rust: only treat as valid when sizes match exactly\nfn size_matches(meta: &std::fs::Metadata, expected: u64) -> bool {\n    meta.len() == expected\n}","tryCatchPattern":"// Rust\nmatch download_artifact(artifact).await {\n    Err(e) if e.to_string().contains(\"stored\") => {\n        // size mismatch: purge and retry once\n        let _ = fs::remove_file(&file_path).await;\n        download_artifact(artifact).await\n    }\n    other => other,\n}","preventionTips":["Retry downloads on a direct, stable connection without proxies or captive portals.","Verify Content-Length from the server matches the manifest before trusting a download.","Pin model versions so exact_bytes in the manifest matches the served file.","Write downloads to a temp file and atomically rename after size verification."],"tags":["download","integrity","network","rust"],"backgroundTag":"checksum-mismatch","analyzedSha":"a2cb62e827da7ef59f65064c97233efb2313878e","analyzedAt":"2026-09-12T11:12:14.152Z","contentChangedAt":"2026-09-12T11:12:14.152Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}