Repository navigation
Description
Found while reviewing #323. Pre-existing on main, not introduced by that PR.
What happens
apps/web/src/app/api/webhooks/slack/route.ts resolves which Orbit workspace an inbound Slack event belongs to by matching the Slack team id against integration.external_id:
.where(and(eq(schema.integration.provider, 'slack'), eq(schema.integration.externalId, slackTeamId)))Nothing ever writes a Slack team id there. Both callers of ensureSlackIntegration, the OAuth callback in integrations-connect.ts and the install action in api/integrations/slack/route.ts, omit externalId, so it falls back to the literal string default for every workspace.
That lookup therefore never matches, the handler returns early, and Slack link unfurling never fires. The same is true of resolveSlackContext(db, organizationId, slackTeamId) on the line below it.
It fails silently. There is no error, no log, and the Slack event returns 200, so the only symptom is that pasting an Orbit issue link into Slack does nothing.
Why now
#323 moved the Slack team id into integration.config.slackTeamId, because using external_id for it caused reconnects to create a second integration row and split the token, scopes, mapping and channel bindings across two rows. That was the right call, and it also means the correct value now exists in a place the webhook can read.
What to do
Route on config.slackTeamId rather than external_id, in both the workspace lookup and the resolveSlackContext call beneath it. A workspace connected before #323 will have neither, so it needs a backfill or a graceful fallback, and it is worth deciding which.
external_id should probably stop being part of the Slack lookup story entirely, since one Slack workspace maps to one Orbit workspace and the (organization_id, provider, external_id) uniqueness is already doing a different job.
Tests
apps/web/tests/app/api/webhooks/slack/route.test.ts was removed in #280 when Slack was fenced off, which is part of why this went unnoticed. Whatever fixes this should bring back a test that an inbound link_shared event for a connected workspace produces an unfurl call.
Activity
imshashank commentedon Aug 19, 2026
Linked from #323, which is now merged and introduced
config.slackTeamId, so the value this needs already exists.imshashank commentedon Aug 23, 2026
#323 has landed and
config.slackTeamIdis now the source of truth. The implementation decision is:config.slackTeamId, not byexternal_id.resolveSlackContextas though it were the integration external id.external_idalready equals the Slack team id may be used as a narrow compatibility fallback. A legacydefaultrow has no safe way to infer its Slack workspace and must reconnect.link_sharedevent reacheschat.unfurl, that the wrong Slack team cannot borrow another workspace's token, and that legacy fallback and reconnect behavior are explicit.With that scope settled, this is ready for implementation.
ayam04 commentedon Aug 29, 2026
Taking this one. Plan: route the inbound webhook lookup on config.slackTeamId (written since #323), with a graceful fallback via the old external_id path for workspaces connected before #323, and drop external_id from the lookup story after verifying the uniqueness constraint still does its job.