{"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/533346cc374382b41ec5ff70536252b2e96e725c/src/backend/static_helpers.rs#L869-L905","documentation":"verify_artifact checks the downloaded file's byte length against a declared 'size' metadata value. A mismatch means the download is truncated, corrupted, or the declared size is stale, so mise refuses to trust (and install) the artifact.","triggerScenarios":"download_and_install / install_version_ call verify_artifact; opts contains a 'size' key, size_str parses to u64, and file_path.metadata().len() differs from expected_size.","commonSituations":"Interrupted or proxied download, a CDN serving a truncated response, upstream re-uploading a release asset with different content while metadata still lists the old size, filesystem-level truncation on low disk space.","solutions":["Delete the cached/partial download and retry the install","Check disk space on the target filesystem","Compare actual asset size on the release page; report upstream if the release asset changed","Retry later if a CDN/mirror is serving stale content"],"exampleFix":"// before retrying\nrm -rf ~/.cache/mise/downloads/<tool>/<version>\nmise install <tool>@<version>","handlingStrategy":"retry","validationCode":"// compare declared vs actual size before install\ncurl -sL -o artifact <url> && test \"$(stat -c%s artifact)\" = \"$EXPECTED_SIZE\" || echo \"truncated download\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Retry downloads on flaky networks before assuming upstream breakage","Monitor disk space; truncation often comes from a full filesystem","If upstream re-uploads assets, clear mise's download cache"],"tags":["download","size-mismatch","integrity"],"backgroundTag":"checksum-mismatch","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}