Skip to content

fix(OUT-3607): return empty array when QB has no service items - #228

Merged
SandipBajracharya merged 2 commits into
masterfrom
OUT-3607
Apr 20, 2026
Merged

fix(OUT-3607): return empty array when QB has no service items#228
SandipBajracharya merged 2 commits into
masterfrom
OUT-3607

Conversation

@SandipBajracharya

Copy link
Copy Markdown
Collaborator

Summary

  • GET /api/quickbooks/product/qb/item threw ZodError: expected array, received undefined when a QuickBooks company had zero Service items — QB omits the Item key from QueryResponse on empty result sets, so QBItemsResponseSchema.parse(qbItems.Item) received undefined.
  • Fixed by defaulting to [] before parsing in _getAllItems (src/utils/intuitAPI.ts:415). Both callers (product.service.ts#queryItemsFromQB, backfillProductInfo.service.ts) already tolerate an empty array.

Fixes ACCOUNTING-SYNC-2X · Linear OUT-3607

Test plan

  • Verify /api/quickbooks/product/qb/item returns [] (not 500) for a QB sandbox company with no Service items.
  • Regression check: a company with ≥1 Service item still returns the parsed array.
  • Backfill command tolerates the [] return (short-circuits via allQbItems?.find).

🤖 Generated with Claude Code

QuickBooks omits the Item key from QueryResponse when the Item SQL
query matches zero rows, causing QBItemsResponseSchema.parse to throw
a ZodError (expected array, received undefined). Default to [] so the
/api/quickbooks/product/qb/item route and the product backfill
gracefully handle companies with no service items.

Fixes ACCOUNTING-SYNC-2X

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@linear-code

linear-code Bot commented Apr 17, 2026

Copy link
Copy Markdown

@vercel

vercel Bot commented Apr 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
quickbooks-sync Building Building Apr 20, 2026 3:57am
quickbooks-sync (dev) Ready Ready Preview, Comment Apr 20, 2026 3:57am

Request Review

@SandipBajracharya
SandipBajracharya merged commit ab4e0cb into master Apr 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants