mxsm / mxsm/rocketmq-rust

[Bug🐛] read-message-log --version reports a hardcoded 0.2.0 while --version reports 1.0.0

Open
#10,780 1 comment 0 reactions 1 assignee View on GitHub

@shubhambhar007 is already working on this.

Since Sep 19, 2026.

bug🐛 Difficulty level/Easy good first issue help wanted rocketmq-tools crate rust
Dominant language
Rust
Stars
1.5k
Forks
264
Avg merge
1h 34m
Merged PRs (30d)
567

Description

Prerequisites
  • I have searched existing issues and discussions
  • This is a bug, not a question (use Discussions for questions)
Environment
  • OS: any (reproduced on Windows 11)
  • RocketMQ Rust: main branch, commit 776518531
  • Rust: per workspace toolchain in rust-toolchain.toml
Bug Description

The rocketmq-store-inspect binary can report three different things for a
version request, and two of them are wrong.

// rocketmq-tools/rocketmq-store-inspect/src/command_line.rs line 21
#[command(author = "mxsm", version = "0.2.0", about = "RocketMQ CLI(Rust)")]
pub struct RootCli {
// rocketmq-tools/rocketmq-store-inspect/src/command_line.rs lines 32-37
    #[command(
        arg_required_else_help = true,
        author = "mxsm",
        version = "0.2.0",
        about = "read message log file"
    )]
    ReadMessageLog {

0.2.0 is a leftover literal, while the package version in the root
Cargo.toml is 1.0.0, and the binary's own release path prints the real
version from env!("CARGO_PKG_VERSION"):

// rocketmq-tools/rocketmq-store-inspect/src/bin/rocketmq_cli.rs line 46
    println!("version={}", env!("CARGO_PKG_VERSION"));

print_release_version_if_requested only intercepts exactly --version (or
--version --verbose), so every other route reaches clap and uses the
attribute instead.

A related inconsistency: ConsolidateMultipath and DowngradePreflight declare
no version attribute at all, so --version after those subcommand names is
rejected as a bad argument rather than printing a version.

Steps to Reproduce

Run each command from the repository root:

cargo run -q -p rocketmq-store-inspect --bin rocketmq-cli-rust -- --version
cargo run -q -p rocketmq-store-inspect --bin rocketmq-cli-rust -- read-message-log --version
cargo run -q -p rocketmq-store-inspect --bin rocketmq-cli-rust -- downgrade-preflight --version
Expected vs Actual

Expected: every spelling reports the same crate version (1.0.0 on the
current main), or a consistent error if a subcommand does not support
--version at all.

Actual: the three commands disagree.

Logs/Screenshots
$ rocketmq-cli-rust --version
rocketmq-store-inspect
version=1.0.0

$ rocketmq-cli-rust read-message-log --version
rocketmq-store-inspect-read-message-log 0.2.0

$ rocketmq-cli-rust downgrade-preflight --version
ERROR core.argument.invalid: Argument is invalid
Additional Context

A bare version attribute in clap's derive macro expands to
env!("CARGO_PKG_VERSION"), so replacing version = "0.2.0" with a bare
version makes the reported value track the package version without a literal
to keep in sync.

src/command_line.rs already has a mod tests with two parsing tests
(parses_offline_upgrade_commands and parses_verbose_in_any_argument_position),
so the regression test belongs beside them, and tests/cli_output.rs is the
place for the end-to-end assertion on the real binary.

Do not change about, author, or any parsing behaviour beyond the version
attribute. Whether consolidate-multipath and downgrade-preflight should also
accept --version is a small product decision; cover it if the maintainers
confirm it in the issue thread, and otherwise leave those two alone and say so in
the pull request.

Acceptance Criteria

  • read-message-log --version reports the same version as the bare
    --version command.
  • At least one test pins that equality, so a future literal cannot drift
    again.
  • cargo test -p rocketmq-store-inspect passes; note that this suite has a
    pre-existing failure at tests/downgrade_preflight.rs:226 on main, so
    run --test cli_output and --lib while that is open, or say in the pull
    request which targets you ran.

Validation

Run from the repository root:

cargo fmt -p rocketmq-store-inspect -- --check
cargo test -p rocketmq-store-inspect --test cli_output
cargo run -q -p rocketmq-store-inspect --bin rocketmq-cli-rust -- read-message-log --version

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.