Skip to content

Commit

Permalink
allow 422
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincobain2000 committed Feb 9, 2024
1 parent d0ac72c commit 7fc3323
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/pkg/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,19 @@ func (g *Github) VerifyGithubToken(token, orgName, repoName, commit string) erro
return err
}

if resp.StatusCode == 422 {
err := fmt.Errorf("github auth response code is unprocessable entity %d", resp.StatusCode)
g.log.Error(err)
return err
}
if resp.StatusCode >= 400 && resp.StatusCode < 500 {
// on same commit, the response code is 422 which doesn't mean it is not authenticated
if resp.StatusCode == http.StatusUnauthorized ||
resp.StatusCode == http.StatusForbidden ||
resp.StatusCode == http.StatusBadRequest ||
resp.StatusCode == http.StatusNotFound ||
resp.StatusCode >= http.StatusInternalServerError {
err := fmt.Errorf("github auth response code is unauthorized %d", resp.StatusCode)
g.log.Error(err)
return err
}
if resp.StatusCode >= 500 {
err := fmt.Errorf("github auth response code is server error %d", resp.StatusCode)
// if response is not a redirect
if resp.StatusCode == http.StatusMovedPermanently || resp.StatusCode == http.StatusFound {
err := fmt.Errorf("github auth response code is redirect %d", resp.StatusCode)
g.log.Error(err)
return err
}
Expand Down

0 comments on commit 7fc3323

Please sign in to comment.