Skip to content

Commit

Permalink
Fix Crash due to Matrix Validation in non Matrix Pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
khrm committed Jul 3, 2024
1 parent ba287f5 commit 82fc1e6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/apis/pipeline/v1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,13 @@ func validateMatrix(ctx context.Context, tasks []PipelineTask) (errs *apis.Field
// by another PipelineTask that the entire array of results produced by a matrix is consumed in aggregate
// since consuming a singular result produced by a matrix is currently not supported
func findAndValidateResultRefsForMatrix(tasks []PipelineTask, taskMapping map[string]PipelineTask) (resultRefs []*ResultRef, errs *apis.FieldError) {
hasMatrixTask := false
for _, t := range tasks {
if !t.IsMatrixed() && !hasMatrixTask {
continue
}
hasMatrixTask = true

for _, p := range t.Params {
if expressions, ok := p.GetVarSubstitutionExpressions(); ok {
if LooksLikeContainsResultRefs(expressions) {
Expand All @@ -812,6 +818,9 @@ func validateMatrixedPipelineTaskConsumed(expressions []string, taskMapping map[
for _, expression := range expressions {
// ie. "tasks.<pipelineTaskName>.results.<resultName>[*]"
subExpressions := strings.Split(expression, ".")
if len(subExpressions) < 2 {
continue
}
pipelineTask := subExpressions[1] // pipelineTaskName
taskConsumed := taskMapping[pipelineTask]
if taskConsumed.IsMatrixed() {
Expand Down

0 comments on commit 82fc1e6

Please sign in to comment.