Skip to content

Slack link unfurling never fires because inbound events cannot find their workspace #337

Closed

Description

@imshashank

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.

Related: #323, #186, #280.

Activity

  1. added
    bug
    help wanted
    p2 medium
    area: integrations
    size: medium
    points: 3
    on Aug 19, 2026
  2. imshashank commented on Aug 19, 2026

    @imshashank
    ContributorAuthor

    Linked from #323, which is now merged and introduced config.slackTeamId, so the value this needs already exists.

  3. imshashank commented on Aug 23, 2026

    @imshashank
    ContributorAuthor

    #323 has landed and config.slackTeamId is now the source of truth. The implementation decision is:

    • Route inbound events by the validated config.slackTeamId, not by external_id.
    • Stop passing the Slack team id into resolveSlackContext as though it were the integration external id.
    • Add an indexed lookup for the provider plus Slack team id so webhook delivery does not scan every integration row.
    • A legacy row whose non-default external_id already equals the Slack team id may be used as a narrow compatibility fallback. A legacy default row has no safe way to infer its Slack workspace and must reconnect.
    • Log an observable routing failure for an unknown team instead of returning silently.
    • Restore route coverage proving that a signed link_shared event reaches chat.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.

  4. added
    ready
    schema change
    on Aug 23, 2026
  5. ayam04 commented on Aug 29, 2026

    @ayam04
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: integrationsbughelp wantedp2 mediumpoints: 3readyschema changesize: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions