fix(slack): only parse scoped user id for oauth credentials#4781
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview This avoids a wrong join if a non-OAuth path ever supplies Reviewed by Cursor Bugbot for commit 23645a1. Configure here. |
Greptile SummaryThis one-line fix guards the OAuth account lookup in the Slack channels route so it only runs when
Confidence Score: 5/5Safe to merge — the one-line guard is consistent with how credential-access.ts populates resolvedCredentialId and has no effect on today's Slack flows. The change is a single conditional guard that adds an explicit type check before a DB lookup. Reading credential-access.ts confirms that every OAuth code path sets credentialType to 'oauth' (including the legacy account-ID path), so no valid OAuth flow is inadvertently blocked. The service-account path, which previously could cause a no-op account lookup, is now correctly excluded. The fail-safe fallback to is_member remains intact. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant SlackChannelsAPI
participant authorizeCredentialUse
participant DB
Client->>SlackChannelsAPI: POST /api/tools/slack/channels
SlackChannelsAPI->>authorizeCredentialUse: authorize(credentialId, workflowId)
authorizeCredentialUse-->>SlackChannelsAPI: "{ credentialType, resolvedCredentialId, ... }"
alt "credentialType === 'oauth' AND resolvedCredentialId set"
SlackChannelsAPI->>DB: "SELECT accountId FROM account WHERE id = resolvedCredentialId"
DB-->>SlackChannelsAPI: accountRow
SlackChannelsAPI->>SlackChannelsAPI: parseScopedSlackUserId(accountRow.accountId)
note over SlackChannelsAPI: scopedUserId extracted (or null for legacy credentials)
else "credentialType === 'service_account' (skipped by guard)"
note over SlackChannelsAPI: resolvedCredentialId is credential.id, NOT account.id — skip lookup
end
SlackChannelsAPI->>SlackAPI: conversations.list (all channels)
SlackAPI-->>SlackChannelsAPI: channels[]
opt scopedUserId present
SlackChannelsAPI->>SlackAPI: "users.conversations?user=scopedUserId"
SlackAPI-->>SlackChannelsAPI: allowedPrivateChannelIds
end
SlackChannelsAPI->>SlackChannelsAPI: filter channels by privacy + membership
SlackChannelsAPI-->>Client: "{ channels }"
Reviews (2): Last reviewed commit: "chore(slack): trim guard comment" | Re-trigger Greptile |
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 23645a1. Configure here.
Summary
account.idusingauthz.resolvedCredentialId, but that value is anaccount.idonly for OAuth credentials — theservice_accountpath incredential-access.tsreturns acredential.id. Guard the lookup oncredentialType === 'oauth'so it's correct by construction.is_memberfallback, no leak), but this makes intent explicit and avoids a misdirected account lookup if that ever changes.Type of Change
Testing
Tested manually;
tsc,biome, andcheck:api-validationpassChecklist