Skip to content

Merge dev to main: worker-side PM webhook project fix (third Linear shadow)#1341

Merged
zbigniewsobiecki merged 2 commits into
mainfrom
dev
May 11, 2026
Merged

Merge dev to main: worker-side PM webhook project fix (third Linear shadow)#1341
zbigniewsobiecki merged 2 commits into
mainfrom
dev

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

Test plan

  • dev CI green pre-merge
  • Watch main CI + Build and Deploy after merge
  • Post-deploy: user re-moves MNG-638 to Todo → expect run on ucho project, cloning zbigniewsobiecki/ucho (full end-to-end fix at last)

🤖 Generated with Claude Code

zbigniewsobiecki and others added 2 commits May 11, 2026 11:56
Third bug in the Linear router-shadow chain. PR #1332 fixed parseWebhook;
PR #1337 fixed resolveProject; this PR fixes the WORKER-side
re-resolution that overrode both router fixes.

Flow before this PR:

  1. Router parseWebhook → selects ucho (correct after #1332)
  2. Router resolveProject → uses event.projectId (correct after #1337)
  3. Router buildJob → embeds projectId=ucho in the LinearJob ✅
  4. Job enqueued
  5. Worker picks up job, calls processLinearWebhook(payload, ...)
     — WITHOUT forwarding jobData.projectId ❌
  6. processPMWebhook calls integration.lookupProject(event.projectIdentifier)
     — which does loadProjectConfigByLinearTeamId(teamId) and returns
     the FIRST cascade project sharing the team. Returns "cascade"
     instead of "ucho". ❌

Live evidence 2026-05-11 after deploys at 09:55Z and 11:30:58Z (both
router fixes live): webhook ddcee404 had data.projectId 7108c72e (ucho
scope), webhook log showed projectId=ucho with "Coalesced dispatch
scheduled". But the resulting run 5aa8f137 had projectId=cascade and
cloned mongrel-intelligence/cascade. Worker re-resolved.

Fix: pass jobData.projectId through the chain:
worker-entry → process{Trello,Jira,Linear}Webhook → processPMWebhook
as a new `preferredProjectId` parameter. processPMWebhook now uses
loadProjectConfigById(preferredProjectId) when set, falling back to
integration.lookupProject for legacy callers that do not pass it.

Trello / JIRA threading is defensive (their discriminators are
naturally unique per cascade project so no current shadow), but the
symmetric signature keeps the architecture consistent and future-
proofs against multi-cascade-project-per-discriminator configs.

Tests:

- tests/unit/pm/webhook-handler.test.ts: new describe block
  "preferredProjectId (router-selected project)" with 4 scenarios:
  uses loadProjectConfigById when set, withCredentials receives the
  router-selected project.id, falls back to lookupProject when unset,
  fail-closes when preferredProjectId resolves to nothing.
- tests/unit/worker-entry.test.ts: updated 9 existing call-shape
  assertions to include the new projectId trailing arg.

Full suite (9311 unit tests) clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…resolveProject-shadow

fix(worker): use router-selected project in PM webhook handlers
@zbigniewsobiecki zbigniewsobiecki merged commit 350066a into main May 11, 2026
15 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

❌ Patch coverage is 64.70588% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/triggers/jira/webhook-handler.ts 0.00% 2 Missing ⚠️
src/triggers/linear/webhook-handler.ts 0.00% 2 Missing ⚠️
src/triggers/trello/webhook-handler.ts 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant