Uh oh!
There was an error while loading. Please reload this page.
fix(table): return 400 instead of 500 for malformed sort/filter input - #4425
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Introduces Reviewed by Cursor Bugbot for commit 4306ac7. Configure here. |
Greptile SummaryThis PR introduces Confidence Score: 5/5Safe to merge — targeted, well-scoped fix with no logic regressions or security concerns. All changed paths are confined to error-path handling. The new error class is minimal and correctly subclasses No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant RouteHandler as Route Handler (v0/v1)
participant Service as lib/table/service.ts
participant SQL as lib/table/sql.ts
Client->>RouteHandler: GET/PUT/DELETE ?sort=...&filter=...
RouteHandler->>Service: queryRows / bulkUpdate / bulkDelete
Service->>SQL: buildSortClause / buildFilterClause
alt Invalid field / direction / operator (caller error)
SQL-->>Service: throw TableQueryValidationError
Service-->>RouteHandler: propagates
RouteHandler-->>Client: 400 { error: message }
else Programmer error (switch/ALLOWED_OPERATORS drift)
SQL-->>Service: throw Error
Service-->>RouteHandler: propagates
RouteHandler-->>Client: 500 { error: "Failed to query rows" }
else Valid input
SQL-->>Service: SQL clause
Service-->>RouteHandler: rows / result
RouteHandler-->>Client: 200 success
end
Reviews (2): Last reviewed commit: "fix(table): revert default-case throw to..." | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
May 4, 2026
Thanks for the review. Both findings addressed in 4306ac7:
|
waleedlatif1
commented
May 4, 2026
@cursor review |
waleedlatif1
commented
May 4, 2026
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 4306ac7. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
Summary
TableQueryValidationErrorinlib/table/sql.tsand throw it frombuildSortClause/buildFilterClausefor caller-supplied bad input (invalid sort direction, invalid field name, invalid operator)./tables/[id]/rowsGET/PUT/DELETE handlers and return 400 with the original message instead of the generic 500.?sort={"column":"date","direction":"desc"}(wrong shape) silently 500'd; now returns a clear 400 the caller can react to.Type of Change
Testing
Tested manually. All 38 existing
lib/table/__tests__/sql.test.tstests pass (error messages preserved).bun run check:api-validationpasses.Checklist