|  | 
| 11 | 11 | import static io.harness.beans.sweepingoutputs.CISweepingOutputNames.CODE_BASE_CONNECTOR_REF; | 
| 12 | 12 | import static io.harness.data.structure.EmptyPredicate.isEmpty; | 
| 13 | 13 | import static io.harness.data.structure.EmptyPredicate.isNotEmpty; | 
|  | 14 | +import static io.harness.data.structure.HarnessStringUtils.emptyIfNull; | 
| 14 | 15 | import static io.harness.steps.StepUtils.buildAbstractions; | 
| 15 | 16 | 
 | 
| 16 | 17 | import static java.util.Collections.singletonList; | 
|  | 
| 49 | 50 | import io.harness.ci.utils.HostedVmSecretResolver; | 
| 50 | 51 | import io.harness.data.structure.CollectionUtils; | 
| 51 | 52 | import io.harness.delegate.TaskSelector; | 
|  | 53 | +import io.harness.delegate.beans.ErrorNotifyResponseData; | 
| 52 | 54 | import io.harness.delegate.beans.TaskData; | 
| 53 | 55 | import io.harness.delegate.beans.ci.CIExecuteStepTaskParams; | 
| 54 | 56 | import io.harness.delegate.beans.ci.vm.CIVmExecuteStepTaskParams; | 
|  | 
| 61 | 63 | import io.harness.delegate.task.stepstatus.artifact.Artifact; | 
| 62 | 64 | import io.harness.delegate.task.stepstatus.artifact.ArtifactMetadata; | 
| 63 | 65 | import io.harness.encryption.Scope; | 
|  | 66 | +import io.harness.exception.ExceptionUtils; | 
| 64 | 67 | import io.harness.exception.ngexception.CIStageExecutionException; | 
| 65 | 68 | import io.harness.execution.CIDelegateTaskExecutor; | 
| 66 | 69 | import io.harness.helper.SerializedResponseDataHelper; | 
| @@ -269,9 +272,13 @@ public StepResponse handleVmStepResponse(Ambiance ambiance, String stepIdentifie | 
| 269 | 272 |     VmTaskExecutionResponse taskResponse = filterVmStepResponse(responseDataMap); | 
| 270 | 273 |     if (taskResponse == null) { | 
| 271 | 274 |       log.error("stepStatusTaskResponseData should not be null for step {}", stepIdentifier); | 
|  | 275 | +      String errorMessage = filterVmStepErrorResponse(responseDataMap); | 
| 272 | 276 |       return StepResponse.builder() | 
| 273 | 277 |           .status(Status.FAILED) | 
| 274 |  | -          .failureInfo(FailureInfo.newBuilder().addAllFailureTypes(EnumSet.of(FailureType.APPLICATION_FAILURE)).build()) | 
|  | 278 | +          .failureInfo(FailureInfo.newBuilder() | 
|  | 279 | +                           .setErrorMessage(errorMessage) | 
|  | 280 | +                           .addAllFailureTypes(EnumSet.of(FailureType.APPLICATION_FAILURE)) | 
|  | 281 | +                           .build()) | 
| 275 | 282 |           .build(); | 
| 276 | 283 |     } | 
| 277 | 284 | 
 | 
| @@ -443,6 +450,18 @@ private VmTaskExecutionResponse filterVmStepResponse(Map<String, ResponseData> r | 
| 443 | 450 |         .orElse(null); | 
| 444 | 451 |   } | 
| 445 | 452 | 
 | 
|  | 453 | +  private String filterVmStepErrorResponse(Map<String, ResponseData> responseDataMap) { | 
|  | 454 | +    // Filter error response from step | 
|  | 455 | +    for (Map.Entry<String, ResponseData> entry : responseDataMap.entrySet()) { | 
|  | 456 | +      ResponseData responseData = entry.getValue(); | 
|  | 457 | +      if (responseData instanceof ErrorNotifyResponseData) { | 
|  | 458 | +        return emptyIfNull(ExceptionUtils.getMessage( | 
|  | 459 | +            new CIStageExecutionException(((ErrorNotifyResponseData) responseData).getErrorMessage()))); | 
|  | 460 | +      } | 
|  | 461 | +    } | 
|  | 462 | +    return "Error which executing step, please validate the configuration or reach out to [email protected]"; | 
|  | 463 | +  } | 
|  | 464 | + | 
| 446 | 465 |   private void logBackgroundStepForBackwardCompatibility( | 
| 447 | 466 |       CIStepInfo stepInfo, String completeIdentifier, String identifier, String planExecutionId) { | 
| 448 | 467 |     // Right now background step only takes stepGroup id upto 1 level. Logging this to check which all pipelines | 
|  | 
0 commit comments