[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
I maintainer di solito rispondono entro 1 giorno
@MrOmale ci sta già lavorando.
Dal 21/10/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 2
- Fork
- 90
- Merge medio
- 31m
- PR unite (30g)
- 20
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MergeFi/backend
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
bug security
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
bug testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
bug security
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di MergeFi/backend
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
zapcooking/frontend#946 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
WiliamRosa/cosmos-semantic-platform#40 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
liberation-data/drivine#733 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
makecindy/cindy#10062 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno