fix(sdk): preserve self-targeted p tags in add-member and remove-member builders - #6603
Open
BradGroux wants to merge 1 commit into
Open
fix(sdk): preserve self-targeted p tags in add-member and remove-member builders#6603BradGroux wants to merge 1 commit into
BradGroux wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_keyssilently strips theptag matching the signer's pubkey. The relay'svalidate_admin_eventthen callsextract_p_tag, which returnsNone, and the event is rejected.This is the same class of bug as #4906 (PR #4975), which fixed
build_message,build_forum_post, andbuild_forum_comment. The e2e testadd_member_wsalready uses.allow_self_tagging()with a comment explaining the behavior — the SDK builders used by the CLI did not.Added
.allow_self_tagging()tobuild_add_member(kind 9000) andbuild_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 theptag survives signing.add_member_self_target_with_role_preserves_p_tag— same, with aroleadmin tag; asserts both tags survive.remove_member_self_target_preserves_p_tag— signs a kind 9001 self-removal; asserts theptag survives.The existing
add_member_with_role,add_member_without_role, andremove_member_happy_pathtests (which use a non-self target) continue to pass unchanged, confirming the fix does not affect the normal path.Cannot run the full
cargo testsuite 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.