Skip to content

Commit

Permalink
change to 403 error status code (#70)
Browse files Browse the repository at this point in the history
* change to 403 error status code

* adding comment
  • Loading branch information
tzurielweisberg authored Apr 16, 2023
1 parent e35a604 commit f04b553
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/commenter/github/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package github
import (
"context"
"fmt"
"time"

"github.com/google/go-github/v44/github"
"golang.org/x/oauth2"
"time"
)

const githubAbuseErrorRetries = 6
Expand Down Expand Up @@ -86,7 +87,9 @@ func writeCommentWithRetries(owner, repo string, prNumber int, commentFn comment
time.Sleep(time.Second * time.Duration(retrySeconds))

if resp, err := commentFn(); err != nil {
if resp != nil && resp.StatusCode == 422 {
// If we get a 403 or 422, we are being rate or abuse limited by GitHub,
// and we want to retry, while increasing the wait time between retries.
if resp != nil && (resp.StatusCode == 422 || resp.StatusCode == 403) {
abuseError = newAbuseRateLimitError(owner, repo, prNumber, retrySeconds)
continue
}
Expand Down

0 comments on commit f04b553

Please sign in to comment.