buzz icon indicating copy to clipboard operation
buzz copied to clipboard

fix(relay): allow owner to delete archived channels

Open bokiko opened this issue 4 months ago • 1 comments

Summary

Deleting an archived channel currently fails with 400 invalid: channel is archived. Two independent archived-channel guards in the relay reject every mutation on an archived channel except unarchive (kind:9002 with archived=false), so the owner's kind:9008 delete is rejected before it ever reaches its authorization check and delete handler:

  1. crates/buzz-relay/src/handlers/side_effects.rs — the guard in validate_admin_event runs ahead of the per-kind auth match.
  2. crates/buzz-relay/src/handlers/ingest.rs — a second, independent rejection in the ingest path.

This change exempts kind:9008 (delete — a valid terminal transition from archived state) at both guards, using the existing KIND_NIP29_DELETE_GROUP constant (the guard's raw 9002 literal is upgraded to KIND_NIP29_EDIT_METADATA in passing). Authorization is untouched: the 9008 validator arm still runs after the guard and rejects anyone who is not the owner (or the owning human of an owner-role agent), then the existing soft-delete handler runs unchanged.

Related issue

Fixes #2954. Searched open PRs for duplicates — none found.

Testing

  • New e2e regression test test_owner_can_delete_archived_channel (crates/buzz-test-client/tests/e2e_relay.rs): create → archive → unarchive succeeds (9002 exemption intact) → re-archive → non-owner delete rejected with only owner can delete group (proves the auth path still runs, not the archived guard) → owner delete succeeds → post-delete unarchive fails with channel not found (soft-delete took effect).
  • Repro proof: the same test against the unpatched relay fails at the non-owner assertion with invalid: channel is archived — exactly the reported bug.
  • cargo fmt --all --check and cargo clippy --workspace --all-targets -- -D warnings: clean.
  • Workspace tests green: buzz-relay lib (751), buzz-core (45), buzz-auth (229), buzz-db (84), buzz-conformance, buzz-push-gateway. Live e2e suite 37/39 — the 2 failures (test_unarchive_emits_member_added_notification, test_subscription_limit_enforced) are pre-existing and reproduce identically on the unpatched build.

bokiko avatar Jul 26 '26 15:07 bokiko

Ready for review when someone from @block/buzz-oss-team has a moment.

Fixes #2954 — deleting an archived channel failed with invalid: channel is archived. Two independent archived-channel guards rejected kind:9008 before it reached its authorization check, so an owner's delete never got as far as the owner test.

The change exempts kind:9008 at both guards (ingest.rs, side_effects.rs), matching the existing kind:9002 unarchive exemption. Authorization is unchanged — the 9008 arm still runs after the guard and still rejects non-owners.

  • Rebased onto current main (63496cc1); MERGEABLE, no conflicts
  • Semgrep OSS, zizmor, DCO Check all green on 16e9d231
  • cargo test -p buzz-relay — 780 passed, 0 failed, 35 ignored
  • New e2e regression test test_owner_can_delete_archived_channel; confirmed it fails on the unpatched relay at the non-owner assertion with the reported error

Happy to rebase again, split it, or move the test if you'd prefer a different shape.

bokiko avatar Jul 30 '26 10:07 bokiko