Fix Bot Mention Trigger Silently Discarded by Queue Worker Due to Raw Event Name Mismatch

未关闭
#169 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
67/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
github, node.js, typescript

调研方向

Read packages/core/src/review/resolve-job.ts and trace how it loads webhook_deliveries; compare that path with normalization in packages/provider-github/src/webhook.ts and delivery creation in packages/api/src/routes/webhook.ts. Start with the tests around resolveQueuedJob and add coverage for an issue_comment delivery and a closed pull_request delivery. Done means mention reviews and PR-close label cleanup run, existing auto-triggered reviews still work, and the listed typecheck, test, and lint commands pass.

由索引模型根据 Issue 内容生成。

描述

bug good first issue

Summary

Mention-triggered reviews (e.g. @codra review posted as a PR comment) are silently dropped before they ever reach the review worker. The pipeline queues the message, but the worker discards it immediately because it checks for a normalized event name that was never stored.

Root Cause

The webhook handler in packages/api/src/routes/webhook.ts reads the raw GitHub header x-github-event (value: "issue_comment") and stores it in the webhook_deliveries table as-is.

When the queue worker calls resolveQueuedJob in packages/core/src/review/resolve-job.ts, it loads the delivery and checks:

if (eventName !== "change_request" && eventName !== "comment") {
  logger.info(`Queue message ignored: unsupported webhook event ${eventName}`);
  return null;
}

Since delivery.event_name is "issue_comment" (raw GitHub header), not "comment" (the normalized name), the check fails and the message is thrown away. Mention-triggered reviews never execute.

The same mismatch applies to pull_request to change_request for PR-close label cleanup. Any job that takes the fallback path through the delivery lookup (without an inline jobId or payload on the queue message) can be affected.

Affected Files

  • packages/api/src/routes/webhook.ts - stores raw eventName in delivery and passes it raw to the queue message (L274-278)
  • packages/core/src/review/resolve-job.ts - checks normalized names against raw stored names (L42-50)
  • packages/provider-github/src/webhook.ts - normalizeGitHubWebhook correctly maps "issue_comment" to "comment", but is never called on the worker path

Proposed Fix

In resolveQueuedJob, after loading the delivery record, normalize eventName before checking:

// After loading delivery:
const normalized = env.webhooks.normalizePayload(delivery.event_name, delivery.payload);
if (normalized) {
  eventName = normalized.eventName;  // "comment" or "change_request"
  payload = normalized.payload;
} else {
  eventName = delivery.event_name;
  payload = delivery.payload as WebhookPayload;
}

Alternatively (and more robustly), store the normalized event name in webhook_deliveries at insertion time in the webhook route, so the queue always receives the canonical name regardless of which path it takes.

Done When

  • @codra review comments on a PR trigger a review job correctly
  • PR-close label cleanup runs for pull_request closed events
  • Existing auto-triggered PR reviews (opened, synchronize, etc.) continue to work
  • Tests cover the mention trigger path end-to-end through resolveQueuedJob
  • Any backend changes work in both Cloudflare Workers and Node/Docker
  • npm run typecheck, npm test, and npm run lint all pass

Before Closing

  • npm run typecheck, npm test, and npm run lint all pass
  • Any backend changes work in both Cloudflare Workers and Node/Docker
  • Tests cover the changed behavior in each affected runtime
主要语言
TypeScript
星标
125
派生
23
平均合并
2 天 13 小时
30 天内合并 PR
12

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

devarshishimpi/codra 的其他 Issue

查看 devarshishimpi/codra 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。