[Regression on closed #273] assignReward's double-payout guard is keyed on (pool, recipient) instead of (pool, issue) — the same issue can still be paid twice
Maintainer thường phản hồi trong vòng 1 ngày
@MrOmale đang làm issue này rồi.
Từ ngày 21/10/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Problem
#273 ("no guard against being called twice for the same issueId") was closed with this check in MaintenancePoolService.assignReward():
// Guard against double/triple payout for the same issue (#273).
const existingPayment = await this.paymentRepo.findOne({
where: { recipientId: recipientId ?? null },
});
const existingPoolPayment = await this.paymentRepo
.createQueryBuilder('payment')
.innerJoin('payment.escrow', 'escrow')
.where('escrow.maintenancePoolId = :poolId', { poolId: id })
.andWhere('payment.recipientId = :recipientId', { recipientId: recipientId ?? null })
.getOne();
if (existingPoolPayment) {
throw new ConflictException(`Issue ${issueId} has already received a reward from pool ${id}`);
}
issueId doesn't appear in either query, and Payment has no issue column at all. The guard checks who was paid from this pool, not which issue was rewarded:
- The same issue can still be paid twice. Call
assignReward(pool, issue#1, …, recipientA)and thenassignReward(pool, issue#1, …, recipientB), and both succeed. This is the double payout #273 asked to prevent. - Anonymous payouts are never guarded. When
recipientIdis omitted, the query becomespayment.recipientId = NULL, which is never true in SQL. So repeated rewards for the same issue with norecipientIdalways pass. - Legitimate rewards are rejected. A maintainer who fixes two different maintenance issues gets a 409 on the second one, with a misleading message saying that issue was already rewarded.
existingPaymentis dead code. It's an unscoped query across every payment in the system, whose result is never read, and it costs an extra DB round trip per call.
Suggested fix
- Record the rewarded issue on the payment, for example a nullable
Payment.maintenanceIssueId(FK toissues), plus a unique index on(escrowId, maintenanceIssueId). - Guard on
(pool escrow, issueId), and let the unique index close the concurrent-call race. - Remove the unused
existingPaymentquery. - Add tests: the same issue with two recipients gets a 409, and two issues for the same recipient both succeed.
Related: #273, #274, #276.
- Ngôn ngữ chính
- TypeScript
- Star
- 2
- Fork
- 90
- Merge trung bình
- 31 phút
- Pull request đã merge (30 ngày)
- 20
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MergeFi/backend
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của MergeFi/backend
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
zapcooking/frontend#946 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
WiliamRosa/cosmos-semantic-platform#40 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
liberation-data/drivine#733 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
makecindy/cindy#10062 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày