@@ -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) => {
252252const 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