sim icon indicating copy to clipboard operation
sim copied to clipboard

Managed Slack enrollment: conversations.list returns the app's channel view while history calls act as the user

Open mzxchandra opened this issue 2 months ago • 1 comments

Summary

For a credential-group managed Slack enrollment (type managed_oauth, user token verified at enrollment with token_type === 'user' and the full SLACK_MANAGED_USER_SCOPES list including groups:read), tool calls diverge in identity within a single workflow run:

  • slack_v2 get_channel_history on a human-to-human DM of the enrollee succeeds — only the enrollee's user token can read that conversation.
  • slack_v2 list_channels in the same run, bound to the same oauthCredential, returns the app's channel view: only channels the Sim integration is present in, and omits private channels the enrollee is verifiably a member of.

Reproduction (staging workspace 6056c597-cd15-40a5-b6ba-831347b80473)

Run ingest-slack (5a4c8be6-d148-4bd3-8596-dff2d464bd9e), deployed, async, input: {"subject":"[email protected]","credentialId":"ed101c5f-11c8-4580-9704-f2c2c00b4383","kbId":"…","dmChannelIds":"D0BAYR0HS3X"}

Observed in run 518060e5-d667-46f0-9c34-6b9be5627fde (2026-09-05):

  • listChannels output: 17 conversations, all where the Sim app is present; C0AMLFYRZU4 (#rvtech-internal, private) absent even though conversations.members confirms the enrollee U0BB278QRRQ is a member.
  • fetchHistory on D0BAYR0HS3X (a DM between two humans, U0BB278QRRQ and U090GFBMY21): succeeds, 289+ messages written.

Reproduced for a second enrollee ([email protected], credential 6c86b682…, run 0c9ca129…): 20 conversations listed, #rvtech-internal absent despite membership. So it is systematic, not one credential.

Why it matters

Any per-user Slack ingest driven by conversations.list silently sees only app-invited channels, so per-person corpora are built from the app's membership rather than the person's. Downstream this looks like missing data with no error anywhere.

Notes for the fix

  • The enrollment flow stores the authed_user.access_token (user token) — apps/sim/lib/credential-groups/slack-managed-users.ts enforces token_type === 'user'.
  • apps/sim/tools/slack/list_channels.ts builds auth as Bearer ${params.accessToken || params.botToken}; both spans in the repro bind oauthCredential, so the substitution happens in server-side token resolution for the listing path, not in the block config.
  • The custom bot service-account resolver (SLACK_CUSTOM_BOT_PROVIDER_ID in apps/sim/lib/oauth/credential-service.ts) returns the bot token; something appears to route conversations.list (and possibly other non-history reads) through it for managed enrollments.

🤖 Generated with Claude Code

https://claude.ai/code/session_015G1LmfSHrFrrZRsR8dG37Z

mzxchandra avatar Sep 05 '26 01:09 mzxchandra

Closing per repo-owner preference: findings tracked internally. The reproduction and analysis live in the enterprise-search POC's ticket records.

mzxchandra avatar Sep 05 '26 02:09 mzxchandra