From cda017ef4d9e76f0b2863017b3cd47efedff667f Mon Sep 17 00:00:00 2001 From: chavda-bhavik Date: Fri, 22 Dec 2023 15:04:45 +0530 Subject: [PATCH] fix: errors updating to wrong data index --- apps/api/src/app/shared/services/sandbox/contents.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/api/src/app/shared/services/sandbox/contents.ts b/apps/api/src/app/shared/services/sandbox/contents.ts index 9495e8c87..e873aca1c 100644 --- a/apps/api/src/app/shared/services/sandbox/contents.ts +++ b/apps/api/src/app/shared/services/sandbox/contents.ts @@ -44,10 +44,9 @@ function processErrors(batchData, errors) { } let rowIndexToUpdate, combinedErrors, isErrorsEmpty; errors.forEach(error => { - rowIndexToUpdate = error.index - Math.max(0, ((batchData.batchCount - 1)* input.chunkSize)); - rowIndexToUpdate = Math.max(0, rowIndexToUpdate - 1); + rowIndexToUpdate = batchData.data.findIndex(data => data.index === error.index); if( - rowIndexToUpdate <= batchData.batchCount * input.chunkSize && + rowIndexToUpdate > -1 && (typeof error.errors === 'object' && !Array.isArray(error.errors) && error.errors !== null) ) { combinedErrors = Object.assign(batchData.data[rowIndexToUpdate]?.errors || {}, error.errors);