Skip to content

Commit

Permalink
Fix parsing error in case it is UNKNOWN_ERROR
Browse files Browse the repository at this point in the history
  • Loading branch information
nvuillam committed Jan 10, 2025
1 parent 806b282 commit 93013b7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

Note: Can be used with `sfdx plugins:install sfdx-hardis@beta` and docker image `hardisgroupcom/sfdx-hardis@beta`

## [5.14.2] 2025-01-10

- [hardis:project:deploy:smart](https://sfdx-hardis.cloudity.com/hardis/project/deploy/smart/) Fix parsing error in case it is UNKNOWN_ERROR

## [5.14.1] 2025-01-09

- Generate a file **hardis-report/apex-coverage-results.json** with Apex code coverage details for the following commands:
Expand Down
56 changes: 33 additions & 23 deletions src/common/utils/deployTipJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,36 +66,46 @@ export async function analyzeDeployErrorLogsJson(resultJson: any, log: string, i

const detailedErrorLines: string[] = [];

// Fallback in case we have not been able to identify errors
if (errorsAndTips.length === 0 && failedTests.length === 0) {
// Check if there are code coverage warnings
if (resultJson?.result?.details?.runTestResult?.codeCoverageWarnings?.length > 0) {
for (const cvrgWarning of resultJson.result.details.runTestResult.codeCoverageWarnings) {
const coverageErrorMsg = (cvrgWarning.name ? `${cvrgWarning.name} - ` : "") + cvrgWarning.message;
errorsAndTips.push(({
error: { message: coverageErrorMsg },
tip: {
label: "CodeCoverageWarning",
message: "Please fix code coverage so your deployment can pass",
docUrl: "https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_code_coverage_intro.htm",
},
}))
detailedErrorLines.push(...["", "⛔ " + c.red(c.bold("Coverage issue: " + coverageErrorMsg)), ""]);
}
}
else {
// Or add default error message
// Fallback in case we have not been able to identify errors: Check if there are code coverage warnings
if (errorsAndTips.length === 0 && failedTests.length === 0 && resultJson?.result?.details?.runTestResult?.codeCoverageWarnings?.length > 0) {
for (const cvrgWarning of resultJson.result.details.runTestResult.codeCoverageWarnings) {
const coverageErrorMsg = (cvrgWarning.name ? `${cvrgWarning.name} - ` : "") + cvrgWarning.message;
errorsAndTips.push(({
error: { message: "There has been an issue parsing errors, please notify sfdx-hardis maintainers" },
error: { message: coverageErrorMsg },
tip: {
label: "SfdxHardisInternalError",
message: "Declare issue on https://github.com/hardisgroupcom/sfdx-hardis/issues",
label: "CodeCoverageWarning",
message: "Please fix code coverage so your deployment can pass",
docUrl: "https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_code_coverage_intro.htm",
},
}))
detailedErrorLines.push(...["", "⛔ " + c.red(c.bold("There has been an issue parsing errors, please notify sfdx-hardis maintainers")), ""]);
detailedErrorLines.push(...["", "⛔ " + c.red(c.bold("Coverage issue: " + coverageErrorMsg)), ""]);
}
}

// Fallback : declare an error if we have not been able to identify errors
if (errorsAndTips.length === 0 && failedTests.length === 0 && resultJson?.result?.errorMessage) {
errorsAndTips.push(({
error: { message: resultJson.result.errorMessage },
tip: {
label: resultJson.result.errorStatusCode || "UNKNOWN",
message: "Please fix unknown errors (",
},
}))
detailedErrorLines.push(...["", "⛔ " + c.red(c.bold("Unknown issue: " + resultJson.result.errorMessage)), ""]);
}

// Fallback : declare an error if we have not been able to identify errors
if (errorsAndTips.length === 0 && failedTests.length === 0) {
errorsAndTips.push(({
error: { message: "There has been an issue parsing errors, please notify sfdx-hardis maintainers" },
tip: {
label: "SfdxHardisInternalError",
message: "Declare issue on https://github.com/hardisgroupcom/sfdx-hardis/issues",
},
}))
detailedErrorLines.push(...["", "⛔ " + c.red(c.bold("There has been an issue parsing errors, please notify sfdx-hardis maintainers")), ""]);
}

// Create output log for errors
for (const error of errors) {
detailedErrorLines.push(...["", "⛔ " + c.red(c.bold(error.messageInitialDisplay)), ""]);
Expand Down

0 comments on commit 93013b7

Please sign in to comment.