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.
fix(tooling): Plan 027 Phase 6b anti-slop packages/api#326
Re-stacked on #325. Anti-slop 0 in packages/api.
Added 4 commits
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
baseUrlsettings.
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
| Filename | Overview |
|---|---|
| packages/api/src/lib/logging.ts | Introduces structured logging schemas, but the thrown-value schema is too narrow for use at arbitrary catch boundaries. |
| packages/api/src/lib/trpc.ts | Refactors 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.ts | Validates cache and Firecrawl payloads, while error parsing can prevent the documented null fallback. |
| packages/api/src/lib/cache/kv-cache-key.ts | Reworks cache-key normalization without introducing a new currently reachable collision. |
| packages/api/src/lib/session/index.ts | Adds runtime validation of persisted sessions with schemas matching the currently written user records. |
| packages/api/src/lib/integrations/sms/client.ts | Replaces asserted JWT methods with explicit HTTP requests and validates token responses. |
| packages/api/src/routers/admin/product.ts | Centralizes 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
| โฆ | โฆ | @@ -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 | + | ]); | |
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.
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.
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).