@@ -1136,9 +1136,12 @@ func deployStageWaitForWorkRequest(wId *string, entityType string, action oci_de
11361136 }
11371137 }
11381138
1139- // The workrequest may have failed, check for errors if identifier is not found or work failed or got cancelled
1139+ // The workrequest may have failed, check for errors if identifier is not found or work failed or got cancelled.
11401140 if identifier == nil || response .Status == oci_devops .OperationStatusFailed {
1141- return nil , getErrorFromDevopsDeployStageWorkRequest (client , wId , retryPolicy , entityType , action )
1141+ err := getErrorFromDevopsDeployStageWorkRequest (client , wId , retryPolicy , entityType , action )
1142+ if err != nil {
1143+ return nil , err
1144+ }
11421145 }
11431146
11441147 return identifier , nil
@@ -1156,13 +1159,17 @@ func getErrorFromDevopsDeployStageWorkRequest(client *oci_devops.DevopsClient, w
11561159 return err
11571160 }
11581161
1162+ if len (response .Items ) == 0 {
1163+ return nil
1164+ }
1165+
11591166 allErrs := make ([]string , 0 )
11601167 for _ , wrkErr := range response .Items {
11611168 allErrs = append (allErrs , * wrkErr .Message )
11621169 }
11631170 errorMessage := strings .Join (allErrs , "\n " )
11641171
1165- workRequestErr := fmt .Errorf ("work request did not succeed, workId: %s, entity: %s, action: %s. Message: %s" , * workId , entityType , action , errorMessage )
1172+ workRequestErr := fmt .Errorf ("Work Request did not succeed, workId: %s, entity: %s, action: %s. Message: %s" , * workId , entityType , action , errorMessage )
11661173
11671174 return workRequestErr
11681175}
0 commit comments