buzz icon indicating copy to clipboard operation
buzz copied to clipboard

Archived (expired huddle) channel cannot be deleted or unarchived from Desktop: relay returns 400 'channel is archived' for kind 9008 and Desktop's kind 9002

Open rizqcon opened this issue 2 months ago • 1 comments

Summary

An expired ephemeral channel (huddle, ttl_seconds: 3600) that the relay's reaper has archived can no longer be deleted or unarchived from Buzz Desktop. Desktop shows both Unarchive and Delete channel to the channel owner, but the relay rejects both with 400 Bad Request: invalid: channel is archived. The channel is stuck in the owner's community list forever.

Environment

  • Relay: ghcr.io/block/buzz:main (checkout 0020907), self-hosted, single community, Docker compose.
  • Desktop: current Windows build, owner identity.

Steps to reproduce

  1. As community owner, start a huddle (creates an ephemeral private channel with a 1 h TTL).
  2. Let the TTL expire; the relay archives the channel (archived_at set by the reaper).
  3. In Desktop, open the archived channel → channel management → Delete channel.
  4. Observe the dialog: relay returned 400 Bad Request: invalid: channel is archived.
  5. Try Unarchive in the same sheet → same 400.

Relay log for both attempts (owner pubkey redacted):

"route":"/events","status":400,"accepted":false,"kind":9008,"reason":"invalid: channel is archived"
"route":"/events","status":400,"accepted":false,"kind":9002,"reason":"invalid: channel is archived"

Root cause (as far as I can tell)

crates/buzz-relay/src/handlers/ingest.rs rejects every event targeting an archived channel unless it is a kind:9002 carrying the tag ["archived", "false"]:

let is_unarchive = kind_u32 == KIND_NIP29_EDIT_METADATA
    && event.tags.iter().any(|t| { ... parts[0] == "archived" && parts[1] == "false" });
if !is_unarchive { if channel.archived_at.is_some() { return Err(IngestError::Rejected("invalid: channel is archived".into())); } }
  • kind:9008 (delete) is therefore always refused on an archived channel, yet Desktop offers the action.
  • Desktop's Unarchive sends a kind:9002 that the relay does not recognise as an unarchive (no archived=false tag, or a different shape), so it is refused too.
  • buzz channels unarchive from the CLI does send the expected tag and succeeds, so the CLI can work around it; Desktop users cannot.

Expected

Either of:

  1. Allow kind:9008 on archived channels (deleting an archived channel is the common case, and "archive then delete" is the natural flow), or
  2. Have Desktop hide Delete on archived channels and send a relay-recognised unarchive; and give the reaper-archived ephemeral channels a way out (auto-delete after TTL + grace, or allow the owner to delete).

Workaround used

Cleared archived_at on the row in Postgres, then deleted from Desktop. Not something users should need to do.

rizqcon avatar Sep 11 '26 21:09 rizqcon

Same failure here, with an additional observation on the relay side: the archived ephemeral channels are also never purged, so even once delete is fixed there is a second half to this.

Versions: relay 0.2.1 (deploy/compose, Postgres), desktop 0.5.23 (macOS).

What happens

A huddle creates an ephemeral channel (kind 9007, ttl_seconds = 3600). end_huddle archives it immediately.

The TTL reaper (reap_expired_ephemeral_channels in crates/buzz-db/src/store/channel.rs) only sets archived_at; it never deletes. For a huddle channel it does not even fire, because the channel is already archived.

Deleting the archived channel from the desktop app fails with relay returned 400 Bad Request: invalid: channel is archived. The app offers the delete action anyway.

Result: every huddle leaves a huddle-<id> row in channels forever, visible in the channel management and archive views. The only way to remove it is unarchive followed by delete, or a manual SQL cleanup on the relay.

Expected

Either the relay purges archived ephemeral channels (TTL passed, archived_at older than a retention window, e.g. 24 h) together with their events, mentions, thread metadata and memberships, or delete is allowed on an archived channel, at least for ephemeral ones, so the client can remove them.

Steps to reproduce

  1. Start a huddle in any channel, end it.
  2. Wait longer than the TTL (1 h).
  3. Observe the archived huddle-<id> channel still present. Try to delete it from the desktop app: invalid: channel is archived.

Suggestion

A purge_archived_ephemeral_channels step in the existing reaper loop with a configurable retention (default 24 h), plus either hiding the delete action on archived channels in the desktop app or letting the relay accept it. Keeping archived ephemeral channels indefinitely has no user-facing value.

willi-werner avatar Sep 13 '26 07:09 willi-werner