Skip to content

patch error while posting comment too large #1908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 24, 2025
Merged
Changes from 1 commit
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
10 changes: 8 additions & 2 deletions cli/pkg/digger/digger.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,19 @@ func RunJobs(jobs []orchestrator.Job, prService ci.PullRequestService, orgServic
}

if allAppliesSuccess == true && reportFinalStatusToBackend == true {
currentJob := jobs[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Check if jobs array is empty before accessing index 0.

The code retrieves the first job from the jobs array without verifying if the array is empty. If the jobs array is empty, accessing jobs[0] will cause a panic.

Add a check to ensure the jobs array is not empty:

-		currentJob := jobs[0]
+		if len(jobs) == 0 {
+			return false, false, fmt.Errorf("error while sending job comments: %v", err)
+		}
+		currentJob := jobs[0]

Committable suggestion skipped: line range outside the PR's diff.


_, jobPrCommentUrl, err := reporter.Flush()
if err != nil {
log.Printf("error while sending job comments %v", err)
return false, false, fmt.Errorf("error while sending job comments %v", err)
cmt, cmt_err := prService.PublishComment(*currentJob.PullRequestNumber, fmt.Sprintf(":yellow_circle: Warning: failed to post comment for project %v, recieved error: %v.\n\n you may review details in the job logs", currentJob.ProjectName, err))
if cmt_err != nil {
log.Printf("Error while posting error comment: %v", err)
return false, false, fmt.Errorf("failed to post reporter error comment, aborting. Error: %v", err)
}
jobPrCommentUrl = cmt.Url
}

currentJob := jobs[0]
projectNameForBackendReporting := currentJob.ProjectName
// TODO: handle the apply result summary as well to report it to backend. Possibly reporting changed resources as well
// Some kind of generic terraform operation summary might need to be introduced
Expand Down
Loading