fix(db): add missing offering columns to GetActivePurchaseHistory SELECT (production-down) - #1472
Conversation
GetActivePurchaseHistory SELECTed 21 columns but shares scanPurchaseHistoryRow, which scans 24 destinations (offering_class, listing_id, listing_state were added by #808). pgx/v5 Rows.Scan requires field count == destination count, so every real-Postgres call to this query failed with "number of field descriptions must equal number of destinations, got 21 and 24". Impact (all broken on real Postgres, silently in some paths): - dashboard commitment KPIs (fetchCommitmentPurchases swallows the error and renders 0 active commitments / $0 committed monthly / $0 YTD), - GET /api/inventory/commitments and /api/inventory/coverage (return errors), - the analytics collector's Collect (fails every run). #808 (marketplace) added the three columns to the scanner and to GetPurchaseHistory / GetAllPurchaseHistory / GetPurchaseHistoryFiltered but missed GetActivePurchaseHistory. This is the same class of defect #1221 fixed for the 17-vs-21 case. Fix: append offering_class, listing_id, listing_state so the column list is identical to the other purchase-history queries and matches the scanner. Update the pgxmock regex to pin the corrected column list so a future drop of these columns fails the test. Note: pgxmock cannot reproduce the field-count mismatch (it fabricates result columns), so the regression is only guarded via the SQL-text regex here; a shared "emitted SELECT column list == purchaseHistoryCols" assertion across all purchase-history queries is a worthwhile follow-up. Found by the adversarial (Fable) review sweep of recently-merged PRs.
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthrough
ChangesPurchase history projection
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
CRITICAL — dashboard KPIs, inventory endpoints, and analytics collector broken on real Postgres
Found by the adversarial (Fable) review sweep of recently-merged PRs.
GetActivePurchaseHistorySELECTed 21 columns but sharesscanPurchaseHistoryRow, which scans 24 destinations (offering_class, listing_id, listing_statewere added by #808). pgx/v5Rows.Scanrequires field count == destination count, so every real-Postgres call to this query fails:number of field descriptions must equal number of destinations, got 21 and 24.Impact
fetchCommitmentPurchasesswallows the error → fabricated $0 on a money path).GET /api/inventory/commitmentsand/api/inventory/coveragereturn errors.Collectfails every run.Root cause
#808 (marketplace, closes #292) added the three columns to the scanner and to
GetPurchaseHistory/GetAllPurchaseHistory/GetPurchaseHistoryFilteredbut missedGetActivePurchaseHistory. Same defect class as #1221 (17-vs-21).Fix
Append
offering_class, listing_id, listing_stateso the column list is identical to the other purchase-history queries and matches the scanner (verified: 24 == 24, identical toGetAllPurchaseHistory). Updated the pgxmock regex to pin the corrected list.Verification
GetActivePurchaseHistoryandGetAllPurchaseHistoryare now identical (24 each).go build,go vet, fullinternal/configsuite green.Summary by CodeRabbit