2025-09-25 – Shipping Address Badge Reliability
Address Updated Badge False Positives
Problem Identified
- Issue: The orders index was showing the
๐ Address Updatedbadge for nearly every order. - Impact: Team members lost trust in the badge, burned time double-checking shipping details, and worried that the sync/webhook pipeline was still broken.
- History: Multiple prior “fixes” only disabled parts of the pipeline; the underlying comparison treated re-sent Shopify payloads as changes and kept flipping
shipping_updated_at.bgrf
Solution Implemented
- Deterministic Comparison: Normalize incoming and stored shipping records (trimming, lowercasing null-equivalents, JSON ordering) before comparing any fields.
- True Change Detection: Exit early unless at least one normalized field actually changes; only then update the row and timestamp.
- Safer Sync Refresh: Re-enabled the order-sync shipping refresh with guarded JSON parsing so existing records only move when Shopify genuinely edits the address.
- Verbosity for Audits: Added focused debug logs enumerating the specific fields that changed to simplify future investigations.
Follow-Up & Monitoring
- Let natural traffic run; no manual address edit needed to validate the fix.
- Tomorrow morning, spot-check the orders page to confirm badges only appear on the handful of orders with legitimate address edits.
- If any badge still misbehaves, pull the associated DB row and webhook payload for a quick diff using the new logging breadcrumbs.
QuickBooks Invoice Error
Problem Identified
- Issue: Session lookups started selecting
users.customer_id, which isnโt in production, causing/api/auth/sessionto 500 while invoices were being pushed to QuickBooks. - Impact: The UI briefly showed โApplication Errorโ after creating invoices; logs filled with
column u.customer_id does not existnoise.
Solution Implemented
- Join Table Restoration: Updated NextAuth JWT/session queries to pull store/customer context from
user_storesโfulfillment_storesโcustomers, matching the live schema. - Shared Store Helper: Added a
normalizeStoresutility and rewired hooks/APIs (useCustomer, orders/products endpoints) to respect multi-store associations without relying on the missing column. - Type Safety: Extended
next-authtypings so session consumers get structured store data in addition to the derived primary customer fields.
Follow-Up & Monitoring
- After deployment, re-run the QuickBooks invoice flow to confirm no auth/session errors surface.
- Keep an eye on Heroku logs for any lingering
column ... does not existmessagesโshould be silent now. - Schedule the real
users.customer_idmigration separately, once weโre ready to support parallel store assignments without regressions.
