Skip to content

allow bot membership in gdm streams#4871

Open
miguel-nascimento wants to merge 1 commit into
yoni/bots_gdmfrom
miguel/bot-gdm-followup
Open

allow bot membership in gdm streams#4871
miguel-nascimento wants to merge 1 commit into
yoni/bots_gdmfrom
miguel/bot-gdm-followup

Conversation

@miguel-nascimento

@miguel-nascimento miguel-nascimento commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Allows the user stream side of bot gdm. Stacked on #4860

  • Allow GDM streams in validUserMembershipStream() for app users
  • Handle GDM stream type in ownerChainAuthForInviter() (no ownership check needed - authorization is handled by gdmBotSponsorEntitlements() on the GDM stream side)

Claude take on why:


  The event flow:

  1. GDM created with bot
  2. derivedGDMMembershipEvents() → UserPayload_UserMembership for bot
  3. Event added to bot's user stream
  4. validUserMembershipStream() ← BLOCKS HERE (returns false for GDM)
  5. chainAuthForUserMembership() → ownerChainAuthForInviter() ← ERRORS HERE
  6. parentEventForUserMembership() → MemberPayload_Membership for GDM
  7. gdmBotSponsorEntitlements() runs ← PR 4860 added this

  PR 4860 added step 7 - the gdmBotSponsorEntitlements() check.

  My changes fix steps 4 and 5:
  ┌──────┬──────────────────────────────────────────────────────────────────────┬────────────────────────────────────┐
  │ Step │                               Problem                                │               My Fix               │
  ├──────┼──────────────────────────────────────────────────────────────────────┼────────────────────────────────────┤
  │ 4    │ validUserMembershipStream() returns false for GDM streams            │ Remove GDM from the blocked list   │
  ├──────┼──────────────────────────────────────────────────────────────────────┼────────────────────────────────────┤
  │ 5    │ ownerChainAuthForInviter() only handles Space/Channel, errors on GDM │ Add GDM case that returns nil, nil │
  └──────┴──────────────────────────────────────────────────────────────────────┴────────────────────────────────────┘
  Without my changes, the flow dies at step 4 or 5 and never reaches step 7 where PR 4860's entitlement check runs.


@vercel

vercel Bot commented Jan 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
river-sample-app Ready Ready Preview, Comment Jan 15, 2026 6:31am

@cursor

cursor Bot commented Jan 15, 2026

Copy link
Copy Markdown

PR Summary

Allow bot membership in GDMs; refine auth handling

  • Permits app users to join GDM streams by relaxing validUserMembershipStream() (DMs still disallowed for apps)
  • Handles GDM in ownerChainAuthForInviter() by returning no ownership check; bot authorization handled via gdmBotSponsorEntitlements() on the GDM stream side

Written by Cursor Bugbot for commit c173f49. This will update automatically on new commits. Configure here.

@blacksmith-sh

blacksmith-sh Bot commented Jan 15, 2026

Copy link
Copy Markdown

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
node/rpc/TestGDMBotMembership_BotJoinWithSponsor View Logs

Fix in Cursor

// in bot membership events.
// bounce, we want to verify that the initiator of the membership change has appropriate permissions.
// NOTE: DMs use a special inception-based flow for bots. GDMs don't have ownership hierarchy, so bot
// authorization is handled by gdmBotSponsorEntitlements() on the GDM stream side instead of here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bots cannot self-leave GDM streams due to unhandled case

Medium Severity

When a bot initiates its own leave from a GDM, chainAuthForUserMembership() calls addRemoveChannelChainAuthForApp() (since Inviter equals the bot's own address). However, addRemoveChannelChainAuthForApp() only handles STREAM_CHANNEL_BIN and returns an error for GDM streams: "Invalid stream for app join, wanted channel". The PR updated ownerChainAuthForInviter() to return nil, nil for GDMs (handling member-initiated bot additions) but didn't update the self-initiated path. Bots can join GDMs but cannot leave on their own.

Additional Locations (1)

Fix in Cursor Fix in Web

@texuf texuf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it feels good ship it i will review it thoroughly on friday when im back.

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.

2 participants