mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(table): return 400 instead of 500 on empty batch insert (#4329)
The POST /api/table/[tableId]/rows handler called handleBatchInsert without await, so ZodError rejections (e.g. empty rows array) bypassed the route's try/catch and were caught by withRouteHandler as an unhandled error, returning a generic 500 "Internal server error". Add await so validation errors surface as 400s with the actual message.
This commit is contained in:
@@ -232,7 +232,7 @@ export const POST = withRouteHandler(
|
||||
'rows' in body &&
|
||||
Array.isArray((body as Record<string, unknown>).rows)
|
||||
) {
|
||||
return handleBatchInsert(
|
||||
return await handleBatchInsert(
|
||||
requestId,
|
||||
tableId,
|
||||
body as z.infer<typeof BatchInsertRowsSchema>,
|
||||
|
||||
Reference in New Issue
Block a user