Skip to content

fix(router): prefer trigger result work-item id over parse-time field in decisionReason#1239

Merged
zbigniewsobiecki merged 5 commits intodevfrom
fix/decision-reason-resolved-work-item
Apr 29, 2026
Merged

fix(router): prefer trigger result work-item id over parse-time field in decisionReason#1239
zbigniewsobiecki merged 5 commits intodevfrom
fix/decision-reason-resolved-work-item

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

Prod incident 2026-04-29: a respond-to-ci dispatch logged

Job queued: respond-to-ci agent for work item (unknown)

even though the agent fired correctly on the right PR. Root cause: the GitHub adapter's parseWebhook extracts event.workItemId from payload.pull_request.number only — check_suite webhooks store the PR number under payload.check_suite.pull_requests[0].number and the parser leaves the field undefined. The respond-to-ci handler resolves the PR internally and returns it as result.prNumber + result.workItemId, but the decisionReason builder used the parse-time event.workItemId.

The agent itself fired correctly; only the dashboard webhook log was affected.

Fix

New resolveWorkItemLabel(result, event) helper picks the most specific label:

result.workItemId > 'PR #' + result.prNumber > event.workItemId > '(unknown)'

Both the Coalesced dispatch scheduled and Job queued build sites in webhook-processor.ts use it.

Test plan

  • 2 new tests in webhook-processor.test.ts covering the result-over-event preference and the prNumber fallback.
  • All 8751 unit tests pass.
  • All 550 integration tests pass.
  • npm run lint clean.
  • npm run typecheck clean.

🤖 Generated with Claude Code

zbigniewsobiecki and others added 5 commits April 29, 2026 19:05
Merge dev → main: Fix 1 (BullMQ coalesce unique jobIds) + Fix 2 (snapshot rmi on PR merge)
Merge dev → main: backlog-manager scope safety (#1233)
Merge dev → main: respond-to-ci diagnostics + persona-scope hardening (#1235)
Merge dev → main: refactor(triggers) consolidate handler boilerplate (#1237)
… in decisionReason

Prod incident 2026-04-29: a `respond-to-ci` dispatch logged
`Job queued: respond-to-ci agent for work item (unknown)` even though the
agent ran on the right PR. Root cause: the GitHub adapter's `parseWebhook`
extracts `event.workItemId` from `payload.pull_request.number` only —
`check_suite` webhooks store the PR number under
`payload.check_suite.pull_requests[0].number` and the parser leaves the
field undefined. The `respond-to-ci` handler resolves the PR internally
and returns it as `result.prNumber` + `result.workItemId`, but the
decisionReason builder used the parse-time `event.workItemId`.

The agent itself fired correctly; only the dashboard webhook log was
affected. Fix: a `resolveWorkItemLabel(result, event)` helper picks the
most specific label —
`result.workItemId > 'PR #' + result.prNumber > event.workItemId > '(unknown)'`.
Both the `Coalesced dispatch scheduled` and `Job queued` build sites use it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/router/webhook-processor.ts 85.71% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@zbigniewsobiecki zbigniewsobiecki merged commit f9bf06b into dev Apr 29, 2026
9 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the fix/decision-reason-resolved-work-item branch April 29, 2026 23:11
zbigniewsobiecki added a commit that referenced this pull request Apr 29, 2026
Merge dev → main: decisionReason work-item-id resolution (#1239)
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