{"record":{"id":"a65d363de1d18824","repo":"jdx/mise","slug":"transferred-revision-mismatch","errorCode":null,"errorMessage":"transferred revision mismatch","messagePattern":"transferred revision mismatch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/remote_repository.rs","lineNumber":223,"sourceCode":"    let temporary = if dry_run {\n        tempfile::tempdir()?\n    } else {\n        tempfile::tempdir_in(parent)?\n    };\n    let checkout = temporary.path().join(\"checkout\");\n    let shown = crate::file::display_path(destination);\n    let mut command = Command::new(\"git\");\n    crate::git::sanitize_git_command(&mut command);\n    let output = command\n        .args([\"clone\", \"--no-checkout\", \"--\"])\n        .arg(bundle)\n        .arg(&checkout)\n        .output()?;\n    if !output.status.success() {\n        bail!(\"invalid transferred repository bundle\");\n    }\n    if git(&checkout, &[\"rev-parse\", \"HEAD\"])? != revision {\n        bail!(\"transferred revision mismatch\");\n    }\n    let entries = git(&checkout, &[\"ls-tree\", \"-r\", \"-z\", \"--name-only\", revision])?;\n    for entry in entries.split('\\0').filter(|s| !s.is_empty()) {\n        let path = Path::new(entry);\n        if path\n            .components()\n            .any(|c| !matches!(c, std::path::Component::Normal(_)))\n            || entry.split('/').any(|p| p.eq_ignore_ascii_case(\".git\"))\n        {\n            bail!(\"unsafe source repository path\");\n        }\n        if entry.to_ascii_lowercase().ends_with(\".local.toml\") {\n            bail!(\n                \"source contains machine-local configuration ({entry}); remove it from the repository before onboarding\"\n            );\n        }\n    }\n    git(&checkout, &[\"remote\", \"set-url\", \"origin\", origin])?;","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/remote_repository.rs#L205-L241","documentation":"After cloning the bundle, install_at verifies that the checked-out HEAD (`git rev-parse HEAD`) exactly equals the requested pinned revision. If the bundle's HEAD resolves to a different commit, the transfer did not deliver the requested revision and the install aborts rather than installing untrusted or wrong content.","triggerScenarios":"Calling install_at with a revision that exists upstream but was not the HEAD captured in the bundle — e.g. the source repo was re-fetched/advanced between bundle creation and install, or the caller passes a valid-format SHA that the bundle never contained.","commonSituations":"Race where the upstream repository was updated mid-onboarding; caller caching a stale SHA; passing a SHA from a different repository that happens to be valid hex.","solutions":["Re-run the onboarding flow (fetch then install) so the bundle is regenerated for the same revision you pass.","Confirm the SHA exists in the source repo: `git ls-remote <origin> <sha>`.","Ensure the revision you pass is the one resolved at fetch time, not from an older cache."],"exampleFix":"// before\nlet sha = cache.load(\"repo-sha\")?; // stale\ninstall_at(origin, &sha, ...).await?;\n// after\nlet source = Source::fetch(origin.into()).await?;\ninstall_at(origin, &source.revision, ...).await?; // same revision the bundle carries","handlingStrategy":"validation","validationCode":"// ensure the revision you pin is the one Source::fetch captured\nconst source = await fetchSource(origin);\nif (source.revision !== requestedRevision) throw new Error(\"stale revision; refetch\");","typeGuard":null,"tryCatchPattern":"try {\n  await install_at(origin, rev);\n} catch (e) {\n  if (String(e).includes(\"transferred revision mismatch\")) {\n    // refetch the source and use its freshly resolved revision\n  } else throw e;\n}","preventionTips":["Always fetch and install in one flow using the revision returned by Source::fetch.","Never cache SHAs across refetches; verify with `git ls-remote <origin> <sha>`.","Avoid mutating the upstream repo between fetch and install."],"tags":["git","revision","integrity","install"],"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"}