From 39f70045666f4ad47cea9c51eef8df94dd339e07 Mon Sep 17 00:00:00 2001 From: Bao Tran Date: Wed, 29 Jan 2025 11:49:45 -0500 Subject: [PATCH 1/2] fix: showing correct error messages --- src/package/packagePushUpgrade.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/package/packagePushUpgrade.ts b/src/package/packagePushUpgrade.ts index 9673f4cf9..70f6e497a 100644 --- a/src/package/packagePushUpgrade.ts +++ b/src/package/packagePushUpgrade.ts @@ -9,6 +9,7 @@ import path from 'node:path'; import util from 'node:util'; import { Connection, SfError, SfProject } from '@salesforce/core'; import { Schema, QueryResult } from '@jsforce/jsforce-node'; +import { IngestJobV2FailedResults } from '@jsforce/jsforce-node/lib/api/bulk2'; import { PackagePushRequestListQueryOptions, PackagePushRequestListResult, @@ -161,7 +162,7 @@ export class PackagePushUpgrade { await job.poll(); // If there are any errors for a job, write all specific job errors to an output file - const jobErrors = await job.getFailedResults(true); + const jobErrors = await job.getFailedResults(); if (jobErrors.length > 0) { const filePath = await this.writeJobErrorsToFile(pushRequestResult?.id, jobErrors); @@ -187,14 +188,20 @@ export class PackagePushUpgrade { } } - private static async writeJobErrorsToFile(pushRequestId: string, jobErrors: string): Promise { + private static async writeJobErrorsToFile( + pushRequestId: string, + jobErrors: IngestJobV2FailedResults + ): Promise { const outputDir = path.join(process.cwd(), 'job_errors'); const outputFile = path.join(outputDir, `push_request_${pushRequestId}_errors.log`); try { await fs.mkdir(outputDir, { recursive: true }); - await fs.writeFile(outputFile, jobErrors, 'utf-8'); + const errorContent = jobErrors + .map((job, index) => `Job ${index + 1} Error:${JSON.stringify(job?.sf__Error, null, 2)}`) + .join(''); + await fs.writeFile(outputFile, errorContent, 'utf-8'); return outputFile; } catch (error) { throw new SfError('Error when saving job errors to file. ' + (error as Error).message); From 3051f05b3a376d64d78b32f106c48d0d5a31d9b6 Mon Sep 17 00:00:00 2001 From: Bao Tran Date: Wed, 29 Jan 2025 11:58:11 -0500 Subject: [PATCH 2/2] fix: lint --- src/package/packagePushUpgrade.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/package/packagePushUpgrade.ts b/src/package/packagePushUpgrade.ts index 70f6e497a..94c5d0a1c 100644 --- a/src/package/packagePushUpgrade.ts +++ b/src/package/packagePushUpgrade.ts @@ -201,7 +201,9 @@ export class PackagePushUpgrade { const errorContent = jobErrors .map((job, index) => `Job ${index + 1} Error:${JSON.stringify(job?.sf__Error, null, 2)}`) .join(''); + await fs.writeFile(outputFile, errorContent, 'utf-8'); + return outputFile; } catch (error) { throw new SfError('Error when saving job errors to file. ' + (error as Error).message);