From 7ef8d0e24f88153c542a618594613df4e6120307 Mon Sep 17 00:00:00 2001 From: Cristian Dominguez Date: Mon, 25 Nov 2024 19:02:04 -0300 Subject: [PATCH] fix: throw if job didn't process any record --- messages/bulkIngest.md | 9 +++++++++ src/bulkIngest.ts | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/messages/bulkIngest.md b/messages/bulkIngest.md index 0d6f817d..cf943a7d 100644 --- a/messages/bulkIngest.md +++ b/messages/bulkIngest.md @@ -41,6 +41,15 @@ Job has been aborted. You must have the "Bulk API Hard Delete" system permission to use the --hard-delete flag. This permission is disabled by default and can be enabled only by a system administrator. +# error.noProcessedRecords + +Job finished successfully but it didn't process any record. + +# error.noProcessedRecords.actions + +- Check that the provided CSV file is valid. +- View the job in the org: "sf org open -o %s --path '/lightning/setup/AsyncApiJobStatus/page?address=%2F%s'". + # flags.column-delimiter.summary Column delimiter used in the CSV file. diff --git a/src/bulkIngest.ts b/src/bulkIngest.ts index fa30c66d..2d3fc28c 100644 --- a/src/bulkIngest.ts +++ b/src/bulkIngest.ts @@ -148,6 +148,13 @@ export async function bulkIngest(opts: { // send last data update so job status/num. of records processed/failed represent the last update stages.update(jobInfo); + if (jobInfo.numberRecordsProcessed === 0) { + stages.error(); + // remove after W-17099874 gets fixed + // eslint-disable-next-line sf-plugin/no-missing-messages + throw messages.createError('error.noProcessedRecords'); + } + if (jobInfo.numberRecordsFailed) { stages.error(); if (opts.verbose && !opts.jsonEnabled) { @@ -256,6 +263,13 @@ export async function bulkIngestResume(opts: { // send last data update so job status/num. of records processed/failed represent the last update stages.update(jobInfo); + if (jobInfo.numberRecordsProcessed === 0) { + stages.error(); + // remove after W-17099874 gets fixed + // eslint-disable-next-line sf-plugin/no-missing-messages + throw messages.createError('error.noProcessedRecords'); + } + if (jobInfo.numberRecordsFailed) { stages.error();