{"record":{"id":"94543fb1e3212413","repo":"jdx/mise","slug":"size-mismatch-for-expected-got-94543f","errorCode":null,"errorMessage":"Size mismatch for {}: expected {}, got {}","messagePattern":"Size mismatch for (.+?): expected (.+?), got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/backend/mod.rs","lineNumber":4340,"sourceCode":"                )?;\n            } else {\n                bail!(\"Invalid checksum: {checksum}\");\n            }\n        } else if lockfile_enabled {\n            ctx.pr.set_message(format!(\"generate checksum {filename}\"));\n            let hash = hash::file_hash_blake3(file, Some(ctx.pr.as_ref()))?;\n            tv.lock_platforms\n                .entry(platform_key.clone())\n                .or_default()\n                .checksum = Some(format!(\"blake3:{hash}\"));\n        }\n\n        // Handle size verification and generation\n        if let Some(expected_size) = locked.size {\n            ctx.pr.set_message(format!(\"verify size {filename}\"));\n            let actual_size = file.metadata()?.len();\n            if actual_size != expected_size {\n                bail!(\n                    \"Size mismatch for {}: expected {}, got {}\",\n                    filename,\n                    expected_size,\n                    actual_size\n                );\n            }\n        } else if lockfile_enabled {\n            tv.lock_platforms.entry(platform_key).or_default().size = Some(file.metadata()?.len());\n        }\n        Ok(())\n    }\n\n    /// Human-readable identity of the lock entry consulted for `tv` on\n    /// `platform_key`, including the options that distinguish artifact variants.\n    fn describe_lock_entry(&self, tv: &ToolVersion, platform_key: &str) -> String {\n        let options = self\n            .resolve_lockfile_options(&tv.request, &PlatformTarget::from_current())\n            .unwrap_or_default();","sourceCodeStart":4322,"sourceCodeEnd":4358,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/backend/mod.rs#L4322-L4358","documentation":"When a lockfile entry records an expected download size (`locked.size`), mise verifies the downloaded file's byte length matches before using it. A mismatch means the artifact on disk differs from what was locked — truncated download, corrupted cache, or a changed upstream release — so mise refuses to proceed.","triggerScenarios":"Installing a locked tool where the downloaded artifact's file size != locked.size; interrupted/partial download cached on disk; upstream re-released (moved) a tag so the artifact changed after the lock was generated.","commonSituations":"Flaky network leaving a truncated tarball in the cache; a project republished its release assets; switching mirrors/proxies that alter the response.","solutions":["Clear the cached download (remove the tool's download cache dir, e.g. `mise cache clear` or delete ~/.local/share/mise/downloads/<tool>) and reinstall.","Run `mise lock` to regenerate the lockfile if the upstream artifact legitimately changed.","Check network/proxy stability; retry the install on a reliable connection."],"exampleFix":"// before: truncated cached artifact\n$ mise install\nSize mismatch for terraform-1.9.0.zip: expected 27123456, got 12000000\n\n// after: clear cache and reinstall\n$ mise cache clear && mise install","handlingStrategy":"retry","validationCode":"# verify downloaded artifact size against lockfile before install\nstat -c %s <cached-artifact>  # compare with locked.size in mise.lock","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install on stable network connections; avoid interrupting downloads","Clear download caches after network errors","Re-run `mise lock` when upstream re-releases or moves assets"],"tags":["download","size-mismatch","lockfile","verification"],"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"}