Skip to content

Commit d4f699d

Browse files
committed
fix(table): validate positions length matches rows before service call
1 parent 60e7ddb commit d4f699d

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

apps/sim/lib/copilot/tools/server/table/user-table.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,14 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
338338
return { success: false, message: 'Workspace ID is required' }
339339
}
340340

341+
const positions = args.positions as number[] | undefined
342+
if (positions !== undefined && positions.length !== args.rows.length) {
343+
return {
344+
success: false,
345+
message: `positions length (${positions.length}) must match rows length (${args.rows.length})`,
346+
}
347+
}
348+
341349
const table = await getTableById(args.tableId)
342350
if (!table) {
343351
return { success: false, message: `Table not found: ${args.tableId}` }
@@ -351,7 +359,7 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
351359
rows: args.rows,
352360
workspaceId,
353361
userId: context.userId,
354-
positions: args.positions as number[] | undefined,
362+
positions,
355363
},
356364
table,
357365
requestId

0 commit comments

Comments
 (0)