You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(purchase): skip duplicate purchase_history insert on re-drive and add a unique index #704
Re-drive and root retry insert duplicate purchase_history rows. ExistingCommitment is never read, and there is no unique index to stop the second insert. Spend, savings and YTD totals are double counted.
An execution is re-driven (or a root is retried) after the commitment already exists. The code inserts a second history row for the same purchase instead of skipping it, so dashboards and savings reports count it twice. Found by source reading; not run against Postgres.
Suggested fix
Skip the history insert when ExistingCommitment is set.
Add a dedupe migration and a unique index on (provider, account_id, purchase_id).
Refuse a root retry when completed children exist.
Severity
High: financial totals are wrong, and duplicate rows corrupt data that other features read.
Related: #267 (duplicate purchase_id rows wedging the marketplace listing slot). That issue covers the marketplace-slot symptom; this one covers the insert path that creates the duplicates and the double counted spend.
Reviewer ID: MON-06 (money H6)
Found by the 2026-10-08 review fleet.
Activity
fix(purchase): save purchase history once per commitment (#776)
cristim commentedon Oct 9, 2026
Fixed by #776 (merge 57f42e0). Existing duplicate purchase-history rows are untouched; cleaning them up is a pending owner decision.