Skip to content

Commit

Permalink
fix: also display errors from componentFailures (#816)
Browse files Browse the repository at this point in the history
* fix: also display errors from componentFailures

* refactor: use set for perf reasons

---------

Co-authored-by: mshanemc <[email protected]>
  • Loading branch information
shetzel and mshanemc authored Nov 20, 2023
1 parent a916d3c commit 7b4abbd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/formatters/deployResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,22 @@ export class DeployResultFormatter extends TestResultsFormatter implements Forma
if (this.result.response.status === RequestStatus.Succeeded) return;

const failures = this.relativeFiles.filter(isSdrFailure);
const deployMessages = ensureArray(this.result.response.details?.componentFailures);
if (deployMessages.length > failures.length) {
const failureKeySet = new Set(failures.map((f) => makeKey(f.type, f.fullName)));
// if there's additional failures in the API response, find the failure and add it to the output
deployMessages
.filter((m) => !m.componentType || !failureKeySet.has(makeKey(m.componentType, m.fullName)))
.map((deployMessage) => {
failures.push({
fullName: deployMessage.fullName,
type: deployMessage.componentType ?? 'UNKNOWN',
state: ComponentStatus.Failed,
error: deployMessage.problem ?? 'UNKNOWN',
problemType: deployMessage.problemType ?? 'Error',
});
});
}
if (!failures.length) return;

const columns = {
Expand Down Expand Up @@ -309,3 +325,5 @@ export class DeployResultFormatter extends TestResultsFormatter implements Forma
ux.table(getFileResponseSuccessProps(deletions), columns, options);
}
}

const makeKey = (type: string, name: string): string => `${type}#${name}`;

0 comments on commit 7b4abbd

Please sign in to comment.