Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions cli/pkg/digger/digger.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,15 @@ func RunJobs(jobs []orchestrator.Job, prService ci.PullRequestService, orgServic
return false, false, fmt.Errorf("error while running command: %v", err)
}

err = commentUpdater.UpdateComment(batchResult.Jobs, prNumber, prService, prCommentId)
if err != nil {
slog.Error("error Updating status comment", "error", err)
return false, false, err
// Check if batchResult is nil (can happen with mock backend or when backend is not configured)
if batchResult == nil {
slog.Warn("batchResult is nil, skipping comment update", "jobId", jobId, "prNumber", prNumber)
} else {
err = commentUpdater.UpdateComment(batchResult.Jobs, prNumber, prService, prCommentId)
if err != nil {
slog.Error("error Updating status comment", "error", err, "prNumber", prNumber, "jobId", jobId)
return false, false, err
}
}

}
Expand Down
7 changes: 6 additions & 1 deletion cli/pkg/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ func RunSpec(
message := fmt.Sprintf("Failed run commands. %v", err)
reportError(spec, backendApi, message, err)
}
commentUpdater.UpdateComment(serializedBatch.Jobs, serializedBatch.PrNumber, prService, commentId)
// Check if serializedBatch is nil (can happen with mock backend or when backend is not configured)
if serializedBatch == nil {
slog.Warn("serializedBatch is nil, skipping comment update", "jobId", spec.JobId)
} else {
commentUpdater.UpdateComment(serializedBatch.Jobs, serializedBatch.PrNumber, prService, commentId)
}
reportError(spec, backendApi, fmt.Sprintf("failed to run commands %v", err), err)
}
usage.ReportErrorAndExit(spec.VCS.RepoOwner, "Digger finished successfully", 0)
Expand Down
5 changes: 5 additions & 0 deletions libs/comment_utils/summary/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ func (b BasicCommentUpdater) UpdateComment(jobs []scheduler.SerializedJob, prNum
return err
}

if len(jobSpecs) == 0 {
slog.Warn("no job specs found, cannot update comment", "jobCount", len(jobs))
return nil
}

firstJobSpec := jobSpecs[0]
jobType := firstJobSpec.JobType
jobTypeTitle := cases.Title(language.AmericanEnglish).String(string(jobType))
Expand Down
Loading