Skip to content

Commit 5e4dfc9

Browse files
authored
Fix invalid access to resp on error (#46)
1 parent ae48c57 commit 5e4dfc9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pkg/connector/connector.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,12 @@ func (gh *GitHub) Validate(ctx context.Context) (annotations.Annotations, error)
8585
filterOrgs = false
8686
for {
8787
orgs, resp, err := gh.client.Organizations.List(ctx, "", &github.ListOptions{Page: page})
88-
if resp.StatusCode == http.StatusUnauthorized {
89-
return nil, status.Error(codes.Unauthenticated, "github token is not authorized")
90-
}
9188
if err != nil {
9289
return nil, fmt.Errorf("github-connector: failed to retrieve org: %w", err)
9390
}
94-
91+
if resp.StatusCode == http.StatusUnauthorized {
92+
return nil, status.Error(codes.Unauthenticated, "github token is not authorized")
93+
}
9594
for _, o := range orgs {
9695
orgLogins = append(orgLogins, o.GetLogin())
9796
}

0 commit comments

Comments
 (0)