{"record":{"id":"d0ddca6d10f429a5","repo":"BoundaryML/baml","slug":"checksum-mismatch-expected-expected-got-actual","errorCode":null,"errorMessage":"Checksum mismatch: expected {expected}, got {actual}","messagePattern":"Checksum mismatch: expected (.+?), got (.+?)","errorType":"exception","errorClass":"BamlSysError","httpStatus":null,"severity":"critical","filePath":"languages/rust/baml-sys/src/error.rs","lineNumber":49,"sourceCode":"    VersionMismatch { expected: String, actual: String },\n\n    /// Platform not supported.\n    #[error(\"Platform not supported: {os}/{arch}\")]\n    UnsupportedPlatform {\n        os: &'static str,\n        arch: &'static str,\n    },\n\n    /// Failed to determine cache directory.\n    #[error(\"Failed to determine cache directory: {0}\")]\n    CacheDir(String),\n\n    /// Download failed.\n    #[error(\"Failed to download library: {0}\")]\n    DownloadFailed(String),\n\n    /// Checksum mismatch after download.\n    #[error(\"Checksum mismatch: expected {expected}, got {actual}\")]\n    ChecksumMismatch { expected: String, actual: String },\n\n    /// IO error.\n    #[error(\"IO error: {0}\")]\n    Io(#[from] std::io::Error),\n\n    /// Library already initialized with different path.\n    #[error(\"Library already initialized from {existing_path}, cannot change to {requested_path}\")]\n    AlreadyInitialized {\n        existing_path: PathBuf,\n        requested_path: PathBuf,\n    },\n}\n\n/// Result type for baml-sys operations.\npub type Result<T> = std::result::Result<T, BamlSysError>;\n","sourceCodeStart":31,"sourceCodeEnd":66,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/languages/rust/baml-sys/src/error.rs#L31-L66","documentation":"After downloading the BAML native library, baml-sys hashes the downloaded file and compares it against the expected checksum; this error fires when they differ, indicating a corrupted, truncated, or tampered download. The library refuses to use the file to protect against running altered native code. The message shows both the expected and actual digests.","triggerScenarios":"Downloading the library when the transfer is truncated or corrupted, a caching proxy serves a stale/partial file, an artifact was replaced on the server while the client expects a pinned checksum, or the local cache write was corrupted.","commonSituations":"Flaky CI networks producing partial downloads, transparent HTTP proxies mangling binaries, version upgrades where the client's expected checksum no longer matches a re-published artifact, or disk corruption in the cache directory.","solutions":["Delete the cached/downloaded file and retry the download (usually a transient corruption)","Clear the whole baml cache directory to force a clean re-download","Check for a proxy or mirror intercepting and altering the download","Verify you are not mixing BAML client versions with mismatched pinned checksums","Manually verify the artifact hash against the official published checksum"],"exampleFix":"// before\n# corrupted cache reused\n// after\nrm -rf ~/.cache/baml && rerun","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match baml_sys::init() {\n    Err(BamlSysError::ChecksumMismatch { expected, actual }) => {\n        eprintln!(\"corrupt download (expected {expected}, got {actual}); clearing cache\");\n        clear_baml_cache();\n        // one clean retry\n    }\n    other => other.map(|_| ())?,\n}","preventionTips":["Clear the cache after any interrupted install or network failure","Avoid untrusted mirrors/proxies that can alter binary artifacts","Keep client and library versions in lockstep so pinned checksums match","Monitor for repeated mismatches from the same host (indicates tampering or a broken proxy)"],"tags":["rust","checksum","security","download","native-library"],"backgroundTag":"checksum-mismatch","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}