cz bump crashes with version_provider=cargo on workspace virtual manifest (missing [package] / TypeError on version.workspace) · Issue #1732 · commitizen-tools/commitizen · GitHub
Skip to content

cz bump crashes with version_provider=cargo on workspace virtual manifest (missing [package] / TypeError on version.workspace) #1732

Description

@jcfangc

Description

Commitizen crashes when using version_provider = "cargo" on a Cargo workspace virtual manifest (root Cargo.toml contains [workspace] and [workspace.package] but no [package]). Our workspace members inherit version via version.workspace = true. Running cz bump fails inside commitizen/providers/cargo_provider.py while trying to update Cargo.lock.

This prevents using Commitizen’s cargo provider for monorepo-style Rust workspaces where the version is centralized in [workspace.package].version.

Steps to reproduce

  1. Create a Cargo workspace that uses a virtual manifest at the root (no [package]), with a centralized version:

    # ./Cargo.toml (workspace root)
    [workspace]
    members = ["crates/a"]
    
    [workspace.package]
    version = "0.1.0"
    edition = "2024"
  2. Create a member crate that inherits the version via version.workspace = true:

    # ./crates/a/Cargo.toml
    [package]
    name = "a"
    version.workspace = true
    edition.workspace = true
  3. Configure Commitizen to use the cargo provider:

    # ./cz.toml
    [tool.commitizen]
    name = "cz_conventional_commits"
    version_scheme = "semver"
    version_provider = "cargo"
    tag_format = "v$version"
    update_changelog_on_bump = true
  4. Run:

    cz bump --yes
  5. Observe the crash inside commitizen/providers/cargo_provider.py (during manifest parsing / Cargo.lock update).

Current behavior

cz bump crashes with exceptions from cargo_provider.py:

  • tomlkit.exceptions.NonExistentKey: 'Key "package" does not exist.' (root manifest has no [package])
  • then TypeError: string indices must be integers, not 'str' (when accessing package_content["version"]["workspace"] for members)

The command terminates without completing the bump/tag operation.

Desired behavior

cz bump should support Cargo workspaces with a virtual manifest (root Cargo.toml has [workspace] / [workspace.package] but no [package]) and members using version.workspace = true.

Concretely:

  • Read and bump the canonical version from [workspace.package].version.
  • Do not assume [package] exists in the workspace root manifest.
  • When scanning/updating member manifests, correctly handle version.workspace = true (a nested table / boolean) without type errors.

Screenshots

No response

Environment

(computation) juncheng@localhost:~/projects/computation$ cz version --report
Commitizen Version: 4.10.1
Python Version: 3.11.12 (main, Apr 9 2025, 04:04:00) [Clang 20.1.0 ]
Operating System: Linux

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions