Skip to content
Back to snapcart-api report
Code QualityMedium

Unsafe `any` Propagation

src/services/inventory.ts:102

What's going on

A terse cast is used to silence a type mismatch, and the resulting any silently passes through three layers of the inventory service.

Why it matters

Each any bypasses the type checker at a boundary where a refactor could skew a field silently — precisely the bugs tests usually miss.

src/services/inventory.ts:102

Recommended Fix

Replace the inline query with a parameterized statement and validate the id before it ever reaches the database. A regression test is generated alongside the patch.

Before
1const item = raw as any; // unsafe2return stock.sync(item);
After
1const item = InventoryItemSchema.parse(raw);2return stock.sync(item);
  1. Uploaddone
  2. Analyzedone
  3. Finddone
  4. Explainactive
  5. Fixupcoming
  6. Testupcoming
  7. Verifyupcoming