Skip to content

fix(relay): allow owner to delete archived channels - #2988

Open
bokiko wants to merge 1 commit into
block:mainfrom
bokiko:fix/2954-allow-delete-archived-channel
Open

fix(relay): allow owner to delete archived channels#2988
bokiko wants to merge 1 commit into
block:mainfrom
bokiko:fix/2954-allow-delete-archived-channel

Conversation

@bokiko

@bokiko bokiko commented Jul 26, 2026

Copy link
Copy Markdown

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
bokiko requested a review from a team as a code owner July 26, 2026 15:19
@bokiko
bokiko force-pushed the fix/2954-allow-delete-archived-channel branch 2 times, most recently from ad2c31d to 6c5470e Compare July 26, 2026 20:18
Both archived-channel guards (validate_admin_event and the ingest path)
exempted only kind:9002 with archived=false, so an owner's kind:9008
DELETE_GROUP on an archived channel was rejected with "channel is
archived" before its owner-only authorization ever ran. The user-visible
case is auto-archived huddle channels, which could never be deleted.

Exempt kind:9008 at both guard sites. Authorization is unchanged: the
9008 validator arm still runs after the guard and rejects non-owners
with "only owner can delete group".

Adds an e2e regression test covering owner delete of an archived channel,
non-owner delete still failing the owner check (not the archived guard),
and the 9002 unarchive exemption staying intact.

Fixes block#2954

Signed-off-by: bokiko <bokiko@gmail.com>
@bokiko
bokiko force-pushed the fix/2954-allow-delete-archived-channel branch from 6c5470e to 16e9d23 Compare July 30, 2026 10:07
@bokiko

bokiko commented Jul 30, 2026

Copy link
Copy Markdown
Author

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.

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.

Deleting an auto-archived huddle channel returns 400 "channel is archived"

1 participant