vectordotdev/vector · error

expected package version

Error message

expected package version {expected_version}, found {current_version}

What it means

`update_vector_package_version` parses the repo's Cargo.toml and only rewrites `package.version` if the current value exactly matches the expected (pre-release) version derived from the prepare step. A mismatch means the workspace's Cargo.toml was already bumped, manually edited, or is not at the version the release script expects, so it refuses to proceed rather than silently overwriting.

Solutions

  1. Check `package.version` in Cargo.toml and compare it with the version you passed to prepare.
  2. If a previous run already bumped it, either reset Cargo.toml (`git checkout Cargo.toml`) and re-run, or continue from the already-prepared state.
  3. If the version argument is wrong, re-run prepare with the version that matches the current Cargo.toml state.
  4. Ensure the command runs from the repo root (prepare sets cwd via find_repo_root).

Example fix

// before: Cargo.toml already at 0.46.0, re-running prepare for 0.46.0
expected package version 0.46.0-dev.0, found 0.46.0
// after: reset the workspace first
$ git checkout Cargo.toml Cargo.lock
$ vdev release prepare 0.46.0 0.12.0
Defensive patterns

Strategy: validation

Validate before calling

# verify Cargo.toml is at the expected pre-release version first
grep -m1 '^version' Cargo.toml # compare with the version prepare expects

Try / catch

match prepare_result {
    Err(e) if e.to_string().contains("expected package version") => {
        eprintln!("Cargo.toml is at an unexpected version; inspect git status / previous prepare runs");
    }
    r => r?,
}

Prevention

When it happens

Trigger: Running `vdev release prepare` when Cargo.toml's `package.version` differs from `expected_version` — e.g. a previous prepare already bumped it, someone hand-edited Cargo.toml, or a merge changed the version field.

Common situations: Re-running prepare after a partial/failed run, preparing a hotfix while the master Cargo.toml was already bumped for the next minor, or a typo in the version argument.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of vectordotdev/vector@0d4ab78a4f (2026-09-16). Data as JSON: /api/errors/c9a3260604aa320c. Report an issue: GitHub.

Appendix: source

Thrown at vdev/src/commands/release/prepare.rs:297

    vrl_table.insert("version", vrl_version.into());

    Ok(doc.to_string())
}

pub(super) fn update_vector_package_version(
    cargo_toml_contents: &str,
    expected_version: &str,
    release_version: &str,
) -> Result<String> {
    let mut doc = cargo_toml_contents
        .parse::<DocumentMut>()
        .context("Failed to parse Cargo.toml")?;
    let current_version = doc["package"]["version"]
        .as_str()
        .context("package.version should be a string")?;

    if current_version != expected_version {
        bail!("expected package version {expected_version}, found {current_version}");
    }

    doc["package"]["version"] = toml_edit::value(release_version);
    Ok(doc.to_string())
}

fn format_vrl_changelog_block(changelog: &str) -> String {
    let double_tab = "\t\t";
    let body = changelog
        .lines()
        .map(|line| {
            let line = line.trim();
            if line.starts_with('#') {
                format!("{double_tab}#{line}")
            } else {
                format!("{double_tab}{line}")
            }
        })

View on GitHub (pinned to 0d4ab78a4f)