buzz icon indicating copy to clipboard operation
buzz copied to clipboard

buzz messages thread silently returns partial result for wrong channel

Open oletillmann opened this issue 3 months ago • 0 comments

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

Summary

buzz messages thread --channel <A> --event <event from B> 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=<root>, reply.

Wrong channel:

$ 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:

$ 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:

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.

oletillmann avatar Aug 13 '26 20:08 oletillmann