Harden Slack team chat bridge delivery - #540
Conversation
|
@wflanagan is attempting to deploy a commit to the Inbox Zero Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR hardens the Slack team-chat bridge’s workspace isolation and retry behavior.
|
| Filename | Overview |
|---|---|
| apps/api/src/team-chat-bridge.ts | Adds atomic delivery reservation, stale-delivery recovery, stable send keys, and crash-safe ambient-trigger promotion; the previously reported reservation reacquisition issue is fixed. |
| packages/adapters/src/slack-team-chat.ts | Pins inbound events to the authenticated workspace and maps stable send keys to per-chunk Slack client message IDs. |
| packages/adapter-kit/src/types.ts | Extends provider-neutral team-chat sends with an optional stable idempotency key. |
| apps/api/src/team-chat-bridge.test.ts | Adds regression coverage for trigger promotion and prevention of immediate reacquisition of reserved deliveries. |
| packages/adapters/src/slack-team-chat.test.ts | Covers cross-workspace rejection, workspace configuration parsing, and per-chunk outbound idempotency IDs. |
Sequence Diagram
sequenceDiagram
participant Bridge as TeamChatBridge
participant DB as Prisma
participant Slack as Slack API
Bridge->>DB: Reserve running message as delivering
DB-->>Bridge: Reservation acquired
Bridge->>Slack: chat.postMessage(client_msg_id)
Slack-->>Bridge: Message timestamp
Bridge->>DB: Mark delivered and persist handle
Note over Bridge,DB: Expired reservations return to running
Bridge->>Slack: Retry with the same client_msg_id
Slack-->>Bridge: Deduplicated result
Reviews (2): Last reviewed commit: "fix: harden Slack team chat bridge" | Re-trigger Greptile
c144486 to
6ca8792
Compare
Playwright screenshotsFeature frames for this PR:
Open screenshot gallery · Dashboard · CI run Updated for commit |
Why
Greptile flagged recoverability/security issues on #538 before it goes to production. This ports the targeted hardening patch onto the #538 branch.
What changed
auth.test, with optionalSLACK_WORKSPACE_IDvalidation.client_msg_idvalues.observedtoreceivedbefore marking the rest ignored, avoiding a crash window that could discard the trigger.Tested
pnpm exec biome check .env.example apps/api/src/team-chat-bridge.ts apps/api/src/team-chat-bridge.test.ts packages/adapter-kit/src/types.ts packages/adapters/src/slack-team-chat.ts packages/adapters/src/slack-team-chat.test.tspnpm checkpnpm exec vitest run apps/api/src/team-chat-bridge.test.ts packages/adapters/src/slack-team-chat.test.ts apps/api/src/env.test.ts packages/contracts/src/index.test.ts