{"record":{"id":"a315219df7aca1e3","repo":"jdx/mise","slug":"size-mismatch-expected-got","errorCode":null,"errorMessage":"Size mismatch: expected {}, got {}","messagePattern":"Size mismatch: expected (.+?), got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/backend/static_helpers.rs","lineNumber":887,"sourceCode":"    file_path: &Path,\n    opts: &crate::toolset::ToolVersionOptions,\n    pr: Option<&dyn SingleReport>,\n) -> Result<()> {\n    // Check platform-specific checksum first, then fall back to generic\n    let checksum = lookup_with_fallback(opts, \"checksum\");\n\n    if let Some(checksum) = checksum {\n        verify_checksum_str(file_path, &checksum, pr)?;\n    }\n\n    // Check platform-specific size first, then fall back to generic\n    let size_str = lookup_with_fallback(opts, \"size\");\n\n    if let Some(size_str) = size_str {\n        let expected_size: u64 = size_str.parse()?;\n        let actual_size = file_path.metadata()?.len();\n        if actual_size != expected_size {\n            bail!(\n                \"Size mismatch: expected {}, got {}\",\n                expected_size,\n                actual_size\n            );\n        }\n    }\n\n    Ok(())\n}\n\npub(crate) fn verify_checksum_str(\n    file_path: &Path,\n    checksum: &str,\n    pr: Option<&dyn SingleReport>,\n) -> Result<()> {\n    if let Some((algo, hash_str)) = checksum.split_once(':') {\n        hash::ensure_checksum(file_path, hash_str, pr, algo)?;\n    } else {","sourceCodeStart":869,"sourceCodeEnd":905,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/backend/static_helpers.rs#L869-L905","documentation":"In verify_artifact (src/backend/static_helpers.rs:887), mise compares the downloaded artifact's on-disk size against the expected size declared in the backend's metadata (via lookup_with_fallback on the \"size\" option). If the file's actual byte length differs from the declared size, the download is assumed corrupt or truncated and installation aborts.","triggerScenarios":"Installing a backend artifact whose \"size\" metadata exists but does not match the downloaded file: an interrupted/proxied download, a mirror serving a rewritten file, an upstream release asset replaced without updating the size field, or a transparent proxy injecting content.","commonSituations":"Corporate proxy or captive portal replaces the asset with an HTML error page; CDN cache poisoning; upstream maintainer re-tags/replaces a release asset; disk-full truncation during download.","solutions":["Delete the partial download and retry the install (mise install <tool> --force) to rule out truncation.","Check whether a proxy/mirror is intercepting downloads (HTTP_PROXY, corporate TLS inspection) and bypass it for release hosts.","Verify the upstream release asset has not been replaced/re-tagged; if so, wait for the backend metadata to be updated or pin the previous version.","Report the mismatch to the backend maintainer if the declared size is stale."],"exampleFix":"// before: corrupt cached artifact causes repeated failure\nmise install node@22\n// after: clear the download and reinstall\nrm -rf ~/.cache/mise/downloads/<tool>/<version>\nmise install node@22 --force","handlingStrategy":"validation","validationCode":"// check expected vs actual size before installing\nlet meta = std::fs::metadata(&artifact_path)?;\nlet expected: u64 = cfg.get(\"size\").parse()?;\nif meta.len() != expected {\n    eprintln!(\"artifact size {} != expected {} — redownload\", meta.len(), expected);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Retry downloads on flaky networks and keep the size check as the gate.","Avoid transparent proxies/TLS interception for release artifact hosts.","Pin versions whose release assets are known-stable; beware re-tagged releases.","Keep mise's download cache clean so truncated files are not reused."],"tags":["download","integrity","file-size","installation"],"backgroundTag":"checksum-mismatch","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}