Skip to content

fix(sdk): preserve self-targeted p tags in add-member and remove-member builders - #6603

Open
BradGroux wants to merge 1 commit into
block:mainfrom
BradGroux:fix/add-member-self-tagging
Open

fix(sdk): preserve self-targeted p tags in add-member and remove-member builders#6603
BradGroux wants to merge 1 commit into
block:mainfrom
BradGroux:fix/add-member-self-tagging

Conversation

@BradGroux

Copy link
Copy Markdown
Contributor

Summary

buzz channels add-member --pubkey <own-pubkey> fails with relay error 400: "invalid: missing p tag" because the SDK builder does not call .allow_self_tagging().

When a user adds or removes themselves as a channel member, nostr 0.44's EventBuilder::sign_with_keys silently strips the p tag matching the signer's pubkey. The relay's validate_admin_event then calls extract_p_tag, which returns None, and the event is rejected.

This is the same class of bug as #4906 (PR #4975), which fixed build_message, build_forum_post, and build_forum_comment. The e2e test add_member_ws already uses .allow_self_tagging() with a comment explaining the behavior — the SDK builders used by the CLI did not.

Added .allow_self_tagging() to build_add_member (kind 9000) and build_remove_member (kind 9001).

Related issue

Closes #6568

Testing

Three new unit tests in buzz-sdk:

  • add_member_self_target_preserves_p_tag — signs a kind 9000 event where the target pubkey equals the signer; asserts the p tag survives signing.
  • add_member_self_target_with_role_preserves_p_tag — same, with a role admin tag; asserts both tags survive.
  • remove_member_self_target_preserves_p_tag — signs a kind 9001 self-removal; asserts the p tag survives.

The existing add_member_with_role, add_member_without_role, and remove_member_happy_path tests (which use a non-self target) continue to pass unchanged, confirming the fix does not affect the normal path.

Cannot run the full cargo test suite from this host (no Rust toolchain). The build and test gate will be verified on CI and on a host with the Rust toolchain before merge.

…er builders

When a user adds or removes themselves as a channel member, nostr 0.44's
EventBuilder::sign_with_keys silently strips the p tag matching the
signer's pubkey. The relay then rejects the event as "missing p tag"
because validate_admin_event's extract_p_tag returns None.

This is the same class of bug as block#4906 (PR block#4975), which fixed
build_message, build_forum_post, and build_forum_comment. The e2e test
add_member_ws already uses .allow_self_tagging() with a comment
explaining the behavior; the SDK builders used by the CLI did not.

Added .allow_self_tagging() to build_add_member (kind 9000) and
build_remove_member (kind 9001). Three new unit tests verify that
self-targeted p tags survive signing for both builders, including
add_member with a role tag.

Closes block#6568

Co-authored-by: Brad Groux <brad@digitalmeld.com>
Signed-off-by: Brad Groux <brad@digitalmeld.com>
@BradGroux
BradGroux requested a review from a team as a code owner August 23, 2026 03:44
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.

buzz channels add-member fails

1 participant