Hmbown/CodeWhale · error

plugin source changed after review: expected content hash

Error message

plugin source changed after review: expected content hash {expected}, copied bytes hash is {actual}; nothing was installed

What it means

After the user reviews a plugin source, the library re-stages the bytes and compares the staged content hash to the expected hash recorded at review time. If they differ, something changed between review and install, so it deletes the staged copy and refuses to install anything. This is a TOCTOU/supply-chain guard.

Solutions

  1. Re-run the install flow so the user reviews the current content and a fresh expected hash is recorded
  2. Verify the source has not changed (check file mtime or upstream checksum) and retry
  3. If a remote republished the tarball, pin to a specific version/URL whose bytes match what you reviewed

Example fix

// before: review hash taken, then file edited before confirming
$ codewhale plugin install ./dist --review  # hash abc123
$ (edit dist/plugin.toml)
$ codewhale plugin install ./dist            # mismatch -> bail
// after: re-review so expected == actual
$ codewhale plugin install ./dist --review
$ codewhale plugin install ./dist
Defensive patterns

Strategy: validation

Validate before calling

// after review, before confirming install:
let current = sha256(fs::read(source_path)?);
if current != expected_hash { eprintln!("source changed; re-review"); return; }

Try / catch

match install_inner(...) {
    Err(e) if e.to_string().contains("changed after review") => {
        eprintln!("source moved under you; re-run install with --review");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling `install_inner` / `install_remote_bytes` after user approval when the source file (or remote tarball) was modified, re-downloaded with different bytes, or the staging copy got corrupted between hashing and install.

Common situations: The plugin file was saved again by an editor between `--review` and confirmation; a remote tarball was republished upstream with the same URL; a checksum-pinned update found different bytes at the pinned URL.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/df5f2b732afb041a. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/plugins/install/mod.rs:378

                expected_content_hash,
            )
        }
    }
}

fn verify_expected_content_hash(
    staged: &stage::StagedPlugin,
    expected_content_hash: Option<&str>,
) -> Result<()> {
    let Some(expected) = expected_content_hash else {
        return Ok(());
    };
    if staged.content_hash == expected {
        return Ok(());
    }
    let actual = staged.content_hash.clone();
    let _ = fs::remove_dir_all(&staged.staged_path);
    bail!(
        "plugin source changed after review: expected content hash {expected}, copied bytes hash is {actual}; nothing was installed"
    )
}

/// Stage and finalize an already-downloaded remote tarball. Kept separate
/// from [`install`] so [`update`] can compare the checksum of the bytes it
/// already fetched instead of downloading twice.
#[allow(clippy::too_many_arguments)]
fn install_remote_bytes(
    remote: &InstallSource,
    bytes: &[u8],
    url: &str,
    user_plugins_dir: &Path,
    max_size: u64,
    update: bool,
    name_conflict: &(dyn Fn(&str) -> Option<String> + Send + Sync),
    expected_content_hash: Option<&str>,
) -> Result<PluginInstallOutcome> {

View on GitHub (pinned to 73e0f67d83)