Skip to content

Commit 60e2ecb

Browse files
author
christopherholland-workday
committed
Fix Mass Assignment in Dataset and DatasetRow Operations
1 parent db40c5a commit 60e2ecb

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

packages/server/src/controllers/dataset/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const createDataset = async (req: Request, res: Response, next: NextFunction) =>
5555
)
5656
}
5757
body.workspaceId = workspaceId
58-
const apiResponse = await datasetService.createDataset(body)
58+
const apiResponse = await datasetService.createDataset(body, workspaceId)
5959
return res.json(apiResponse)
6060
} catch (error) {
6161
next(error)

packages/server/src/services/dataset/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,13 @@ const _csvToDatasetRows = async (datasetId: string, csvString: string, firstRowH
196196
}
197197

198198
// Create new dataset
199-
const createDataset = async (body: any) => {
199+
const createDataset = async (body: any, workspaceId: string) => {
200200
try {
201201
const appServer = getRunningExpressApp()
202202
const newDs = new Dataset()
203203
newDs.name = body.name
204204
newDs.description = body.description
205-
newDs.workspaceId = body.workspaceId
205+
newDs.workspaceId = workspaceId
206206
const dataset = appServer.AppDataSource.getRepository(Dataset).create(newDs)
207207
const result = await appServer.AppDataSource.getRepository(Dataset).save(dataset)
208208
if (body.csvFile) {
@@ -252,6 +252,11 @@ const deleteDataset = async (id: string, workspaceId: string) => {
252252
const addDatasetRow = async (body: any) => {
253253
try {
254254
const appServer = getRunningExpressApp()
255+
const dataset = await appServer.AppDataSource.getRepository(Dataset).findOneBy({
256+
id: body.datasetId,
257+
workspaceId: body.workspaceId
258+
})
259+
if (!dataset) throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `Dataset ${body.datasetId} not found`)
255260
if (body.csvFile) {
256261
await _csvToDatasetRows(body.datasetId, body.csvFile, body.firstRowHeaders)
257262
await changeUpdateOnDataset(body.datasetId, body.workspaceId)
@@ -314,6 +319,12 @@ const updateDatasetRow = async (id: string, body: any) => {
314319
})
315320
if (!item) throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `Dataset Row ${id} not found`)
316321

322+
const dataset = await appServer.AppDataSource.getRepository(Dataset).findOneBy({
323+
id: item.datasetId,
324+
workspaceId: body.workspaceId
325+
})
326+
if (!dataset) throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `Dataset Row ${id} not found`)
327+
317328
item.input = body.input
318329
item.output = body.output
319330
const result = await appServer.AppDataSource.getRepository(DatasetRow).save(item)

0 commit comments

Comments
 (0)