Skip to content

fix(cli): messages edit should read '-' from stdin like messages send - #7668

Open
MrSucik wants to merge 1 commit into
block:mainfrom
MrSucik:fix/cli-edit-content-stdin
Open

MrSucik wants to merge 1 commit into
block:mainfrom
MrSucik:fix/cli-edit-content-stdin

Conversation

@MrSucik

@MrSucik MrSucik commented Sep 15, 2026

Copy link
Copy Markdown

messages send documents --content - as "read from stdin" and implements it via
read_or_stdin. messages edit documents nothing and never calls the helper, so
--content - is stored as a literal -.

That is worse than a missing feature: the flag is the natural way to pass a long or
shell-hostile body, it silently succeeds, and it overwrites the message being corrected.
We hit this on a production channel — an edit meant to fix a meeting summary replaced it
with a single bullet.

This routes edit's content through the same helper, documents the flag, and adds an
example to --help. Also adds a read_or_from seam so the sentinel behaviour is unit
testable without touching the process's stdin. read_or_stdin keeps its existing
signature and delegates to the seam, so no caller changes.

Testing

Toolchain 1.95.0 from rust-toolchain.toml. just is not installed on this machine, so
the Justfile's own commands were run directly; cargo-nextest is absent, so cargo test
was used where test-unit prefers nextest.

  • cargo fmt --all — clean, no changes outside the three edited files.
  • cargo clippy -p buzz-cli --all-targets -- -D warnings — passes. (Scoped to buzz-cli
    rather than the Justfile's --workspace; the change touches only this crate.)
  • cargo test -p buzz-cli — 474 passed, 0 failed, including the new
    validate::tests::read_or_from_dash_is_a_sentinel_not_literal_content.

Manual end-to-end proof against a local isolated relay
(./scripts/start-isolated-test-relay.sh, no credentials, no shared or production relay),
A/B on the same relay with the same command:

printf 'x\ny\n' | buzz messages edit --event <ID> --content -

Reading the resulting kind-40003 edit event back out of the relay's database:

CLI build stored content
main (unpatched) -
this branch x\ny\n

As the author notes, the unit test alone would not have caught the original bug — it was a
missing call in edit, not a defect in the helper. The manual A/B above is what actually
covers the regression; the crate has no CLI-surface test harness to encode it in.

`messages send` documents `--content -` as "read from stdin" and implements
it via `read_or_stdin`. `messages edit` documents nothing and never calls the
helper, so `--content -` is stored as a literal `-`, silently overwriting the
message it was meant to correct.

Route edit's content through the same helper, document the flag, and add an
example to --help. Also add a `read_or_from` seam so the sentinel behaviour is
unit testable without touching the process's stdin; `read_or_stdin` keeps its
signature and delegates to it.

Signed-off-by: MrSucik <15636982+MrSucik@users.noreply.github.com>
@MrSucik
MrSucik requested a review from a team as a code owner September 15, 2026 17:33
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is a9dd4d3bd771b47f0efb4e7f6f7329a5921372b5...20a00df0c056b432733e8c68438b0d5bb7078476.
A new review must complete for this exact range. When manual authorization
is required, a Block organization member must comment exactly
@buzz-security-review 20a00df0c056b432733e8c68438b0d5bb7078476 to authorize a new review.
Any previous review applies only to its recorded range.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant