Skip to content

Commit

Permalink
fix nil pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
jkhelil committed Nov 12, 2024
1 parent 227b311 commit 3ea24b4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/chains/formats/slsa/v1/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,16 @@ func buildConfig(ctx context.Context, pro *objects.PipelineRunObjectV1Beta1) Bui

steps := []attest.StepAttestation{}
// tr.Status.TaskSpec.Steps and tr.Status.Steps should be sime size
if tr.Status.TaskSpec == nil || len(tr.Status.TaskSpec.Steps) != len(tr.Status.Steps) {
if tr.Status.TaskSpec == nil {
logger.Errorf("TaskSpec is nil for task run %s. Skipping this task run.", tr.Name)
continue
}

if len(tr.Status.TaskSpec.Steps) != len(tr.Status.Steps) {
logger.Errorf("Mismatch in number of steps for task run %s. TaskSpec steps: %d, Status steps: %d",
tr.Name, len(tr.Status.TaskSpec.Steps), len(tr.Status.Steps))
continue // Skip this task run entirely
continue
}

// Validate and process steps
valid := true
for i, step := range tr.Status.TaskSpec.Steps {
Expand Down

0 comments on commit 3ea24b4

Please sign in to comment.