Skip to content

Commit ef58c9a

Browse files
committed
Don't error out when unable to comment.
Sometimes the issue is found, but Allstar is unable to comment. Don't exit out of the enforce loop on this, just log a Warning and continue. The error I am currently seeing is "403 Commenting is disabled on issues with more than 2500 comments" Signed-off-by: Jeff Mendoza <[email protected]>
1 parent 8f6dabf commit ef58c9a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/issue/issue.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,17 @@ func ensure(ctx context.Context, c *github.Client, issues issues, owner, repo, p
139139
if !strings.Contains(issue.GetBody(), hash) && hasIssueSection(issue.GetBody(), updateSectionName) {
140140
// Comment update and update issue body
141141
commentBody := fmt.Sprintf("The policy result has been updated.\n\n---\n\n%s", text)
142-
comment, _, err := issues.CreateComment(ctx, owner, issueRepo, issue.GetNumber(), &github.IssueComment{
142+
comment, rsp, err := issues.CreateComment(ctx, owner, issueRepo, issue.GetNumber(), &github.IssueComment{
143143
Body: &commentBody,
144144
})
145+
if err != nil && rsp != nil && (rsp.StatusCode == http.StatusGone || rsp.StatusCode == http.StatusForbidden) {
146+
log.Warn().
147+
Str("org", owner).
148+
Str("repo", repo).
149+
Str("area", policy).
150+
Msg("Cannot create new comment on issue")
151+
return nil
152+
}
145153
if err != nil {
146154
return fmt.Errorf("while updating issue: creating comment: %w", err)
147155
}

0 commit comments

Comments
 (0)