Skip to content

Commit c0b6a7f

Browse files
committed
wrap unauthorized err with status code
1 parent 7a0f93e commit c0b6a7f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/connector/connector.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,9 @@ func getOrgs(ctx context.Context, client *github.Client, orgs []string) ([]strin
453453
if isRatelimited(resp) {
454454
return nil, uhttp.WrapErrors(codes.Unavailable, "too many requests", err)
455455
}
456+
if isAuthError(resp) {
457+
return nil, uhttp.WrapErrors(codes.Unauthenticated, "github-connector: failed to retrieve org", err)
458+
}
456459
return nil, fmt.Errorf("github-connector: failed to retrieve org: %w", err)
457460
}
458461
if resp.StatusCode == http.StatusUnauthorized {

pkg/connector/helpers.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,10 @@ func isRatelimited(resp *github.Response) bool {
235235
}
236236
return resp.StatusCode == http.StatusTooManyRequests
237237
}
238+
239+
func isAuthError(resp *github.Response) bool {
240+
if resp == nil {
241+
return false
242+
}
243+
return resp.StatusCode == http.StatusUnauthorized
244+
}

0 commit comments

Comments
 (0)