block / block/buzz

buzz messages thread silently returns partial result for wrong channel

Open
#5,800 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
32.7k
Forks
4.3k
Avg merge
1d 13h
Merged PRs (30d)
253

Description

`buzz messages thread` silently returns a partial thread when `--channel` does not match the event's `h` tag

## Summary

`buzz messages thread --channel --event ` exits 0 and returns the root event from channel B, but no replies. This looks exactly like a valid thread with no replies and can produce false operational conclusions.

Writes already reject the analogous mismatch (`parent event belongs to a different channel`). Reads should also fail clearly, ideally with the same 400-style channel mismatch.

## Reproduction

The root event has `h=2cf6cfd0-b917-4ea0-b2d8-a29dea949b77`. Its direct reply has the same `h` tag and `e=, reply`.

Wrong channel:

```console
$ buzz messages thread \
--channel 17c553b9-363f-461a-8f46-ae11f765ea3b \
--event 0a9882747d0029df3fc9742b0755068a4ae24426b7e1f18cf44800409fdb437f \
--limit 50
[{"content":"@Bumble Rechercheauftrag, sofort, Teillieferung heute Abend genügt.\n…","id":"0a9882747d0029df3fc9742b0755068a4ae24426b7e1f18cf44800409fdb437f","tags":[["h","2cf6cfd0-b917-4ea0-b2d8-a29dea949b77"],…]}]
$ echo $?
0
```

Correct channel:

```console
$ buzz messages thread \
--channel 2cf6cfd0-b917-4ea0-b2d8-a29dea949b77 \
--event 0a9882747d0029df3fc9742b0755068a4ae24426b7e1f18cf44800409fdb437f \
--limit 50
[{"id":"0a9882747d0029df3fc9742b0755068a4ae24426b7e1f18cf44800409fdb437f",…},{"id":"21da7e949c64f00c565b9e3e1fb378f683d327d486bf0e4ce45f90a2f1619122","tags":[["h","2cf6cfd0-b917-4ea0-b2d8-a29dea949b77"],["e","0a9882747d0029df3fc9742b0755068a4ae24426b7e1f18cf44800409fdb437f","","reply"],…]},…]
```

## Cause in current CLI

On main `2693e0db1fc4980a551c2492031812dc4bad985f`, `cmd_get_thread` builds two OR filters:

```rust
let reply_filter = json!({ "#h": [channel_id], "#e": [event_id], ... });
let root_filter = json!({ "ids": [event_id], "limit": 1 });
let resp = client.query_multi(&[reply_filter, root_filter]).await?;
```

The root filter omits `#h`, and the CLI does not validate the returned root's `h` tag against `--channel`. The relay therefore returns a valid root-by-ID result plus zero channel-scoped replies; the CLI formats that as a successful partial thread.

Source: `crates/buzz-cli/src/commands/messages.rs`, `cmd_get_thread`.

## Expected

Before printing a thread, validate that the requested event's `h` tag equals `--channel`. On mismatch, return a non-zero error such as `event belongs to a different channel` rather than a partial result.

Please add a regression test with a root filter result whose `h` tag differs from the requested channel.

Contributor guide

Open the contributing guide

Research direction

Start in crates/buzz-cli/src/commands/messages.rs at cmd_get_thread and reproduce the mismatch using the two channel/event examples from the issue. Inspect the returned root event and add the requested regression test with an h tag that differs from --channel. Done means the command exits non-zero with a clear channel-mismatch error instead of printing a partial thread.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.