From 989ecd1558ee6cb283f8f296e3a3d1ee32adf71e Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Tue, 28 Apr 2026 17:16:53 -0700 Subject: [PATCH] fix(table): return 400 instead of 500 on empty batch insert 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. --- apps/sim/app/api/table/[tableId]/rows/route.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/sim/app/api/table/[tableId]/rows/route.ts b/apps/sim/app/api/table/[tableId]/rows/route.ts index 99e467a20c..a3db48c875 100644 --- a/apps/sim/app/api/table/[tableId]/rows/route.ts +++ b/apps/sim/app/api/table/[tableId]/rows/route.ts @@ -232,7 +232,7 @@ export const POST = withRouteHandler( 'rows' in body && Array.isArray((body as Record).rows) ) { - return handleBatchInsert( + return await handleBatchInsert( requestId, tableId, body as z.infer,