Skip to content

Commit 3a1b8a6

Browse files
fix(tables): restore the workspace ownership check on copilot row deletes
Switching deleteRow/deleteRowsByIds to take a TableDefinition dropped the workspaceId argument that previously scoped the query, and the two branches I added loaded the table without the ownership comparison every other operation in the tool performs — letting a caller delete rows from a table in another workspace. Both now reject a foreign table as not found.
1 parent ba4beb6 commit 3a1b8a6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,10 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
702702
const requestId = generateId().slice(0, 8)
703703
assertNotAborted()
704704
const deleteRowTable = await getTableById(args.tableId)
705-
if (!deleteRowTable) {
705+
// The old signature passed `workspaceId` into `deleteRow`, which scoped
706+
// the query; taking a TableDefinition instead means the ownership check
707+
// has to happen here, as every other operation in this tool does.
708+
if (!deleteRowTable || deleteRowTable.workspaceId !== workspaceId) {
706709
return { success: false, message: `Table ${args.tableId} not found` }
707710
}
708711
await deleteRow(deleteRowTable, args.rowId, requestId)
@@ -1022,7 +1025,7 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
10221025
const requestId = generateId().slice(0, 8)
10231026
assertNotAborted()
10241027
const batchDeleteTable = await getTableById(args.tableId)
1025-
if (!batchDeleteTable) {
1028+
if (!batchDeleteTable || batchDeleteTable.workspaceId !== workspaceId) {
10261029
return { success: false, message: `Table ${args.tableId} not found` }
10271030
}
10281031
const result = await deleteRowsByIds(

0 commit comments

Comments
 (0)