fix(tooling): Plan 027 Phase 6b anti-slop packages/api#326

closed4
feat/027-phase6-anti-slop-shared-server
feat/027-phase6b-anti-slop-api
openedSep 1, 2026byAAviddaram
View on GitHubTwo-way sync enabledPR last imported 19d ago

Re-stacked on #325. Anti-slop 0 in packages/api.

Added 4 commits

  • docs(plan): gauntlet review and typecheck baseline for #322/#3230914133
  • fix(api): tighten boundary parsers flagged by gauntlet review2971d04
  • fix(api): address P1 review feedback on #32351697ad
  • fix(tooling): clear anti-slop baseline in packages/api (Plan 027 Phase 6b)7547620
Synced from GitHub

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Synced from GitHub

Greptile Summary

This PR removes the packages/api anti-slop lint baseline by replacing assertions and broad unknown types with runtime schemas and narrower domain types.

  • Adds Valibot validation for external API responses, KV records, sessions, logging values, and notification payloads.
  • Refactors cache, SMS, QPay, product-update, and error-handling boundaries.
  • Includes type-only cleanup and removes redundant TypeScript baseUrl settings.

Confidence Score: 4/5

The PR appears safe to merge, with a non-blocking robustness issue in the newly narrowed catch-value validation.

The main changed behavior is runtime boundary validation; no blocking failure is established, but unusual legal JavaScript throw values can cause secondary validation errors that skip fallbacks or obscure diagnostics.

Files Needing Attention: packages/api/src/lib/logging.ts, packages/api/src/lib/trpc.ts, packages/api/src/lib/ai-product/amazon-scrape.ts, packages/api/src/lib/ai-product/image-pipeline.ts, packages/api/src/lib/product-search/upstash.ts

Important Files Changed

FilenameOverview
packages/api/src/lib/logging.tsIntroduces structured logging schemas, but the thrown-value schema is too narrow for use at arbitrary catch boundaries.
packages/api/src/lib/trpc.tsRefactors logging and cache middleware around parsed wire values; catch-path parsing can replace or obscure unusual thrown values.
packages/api/src/lib/ai-product/amazon-scrape.tsValidates cache and Firecrawl payloads, while error parsing can prevent the documented null fallback.
packages/api/src/lib/cache/kv-cache-key.tsReworks cache-key normalization without introducing a new currently reachable collision.
packages/api/src/lib/session/index.tsAdds runtime validation of persisted sessions with schemas matching the currently written user records.
packages/api/src/lib/integrations/sms/client.tsReplaces asserted JWT methods with explicit HTTP requests and validates token responses.
packages/api/src/routers/admin/product.tsCentralizes editable-field validation and preserves stock updates through the stock-transition-aware path.

Reviews (1): Last reviewed commit: "fix(api): address P1 review feedback on ..." | Re-trigger Greptile

packages/api/src/lib/logging.tslines 63โ€“70Open thread
โ€ฆโ€ฆ@@ -1,37 +1,147 @@
67+ v.boolean(),
68+ v.null(),
69+ v.record(v.string(), v.union([v.string(), v.number(), v.boolean(), v.null()])),
70+]);
Ggreptile-appsBoton lines 63โ€“70Sep 1, 2026

P2 Narrow thrown-value validation

The new catch handlers parse arbitrary thrown values with thrownErrorWireSchema, which rejects valid JavaScript throw values such as undefined, arrays, and nested objects. The resulting validation error can skip search and image-analysis fallbacks, prevent product-search failure status from being persisted, or obscure the original tRPC error.

Synced from GitHub

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

๐Ÿ—‚๏ธ Base branches to auto review (1)
  • v2

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

โš™๏ธ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: be3d5b44-8eac-4ca5-b544-34e2fd30f85c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ๐Ÿ” Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands.

Closing: this branch's head commit is already in main (Plan 027 lint stack landed via merge 4bf54d3).