Skip to content

Commit f3e8742

Browse files
Merge pull request #103 from ConductorOne/bugfix/wrap_admin_error
[BB-1313] wrap error with permission denied code
2 parents 1622d2d + 0b54946 commit f3e8742

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/connector/connector.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ func (gh *GitHub) Validate(ctx context.Context) (annotations.Annotations, error)
188188
// Only sync orgs that we are an admin for
189189
if strings.ToLower(membership.GetRole()) != orgRoleAdmin {
190190
if filterOrgs {
191-
return nil, fmt.Errorf("access token must be an admin on the %s organization", o)
191+
err := fmt.Errorf("access token must be an admin on the %s organization", o)
192+
return nil, uhttp.WrapErrors(codes.PermissionDenied, "github-connector: credentials validation failed", err)
192193
}
193194
continue
194195
}
@@ -197,7 +198,8 @@ func (gh *GitHub) Validate(ctx context.Context) (annotations.Annotations, error)
197198
}
198199

199200
if !adminFound {
200-
return nil, fmt.Errorf("access token must be an admin on at least one organization")
201+
err := fmt.Errorf("access token must be an admin on at least one organization")
202+
return nil, uhttp.WrapErrors(codes.PermissionDenied, "github-connector: credentials validation failed", err)
201203
}
202204

203205
if len(gh.enterprises) > 0 {

0 commit comments

Comments
 (0)