From 3784f5465ab17d48044171065919c568c7b0ebcd Mon Sep 17 00:00:00 2001 From: Waleed Date: Tue, 28 Apr 2026 17:26:14 -0700 Subject: [PATCH] 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. --- 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,