Skip to content

Commit 24adf6e

Browse files
committed
Improve error message for branch protection permission failure.
Signed-off-by: kash2104 <kparikh1104@gmail.com>
1 parent 66c42b6 commit 24adf6e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

clients/githubrepo/branches.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ func (handler *branchesHandler) query(branchName string) (*clients.BranchRef, er
311311
// Ignore permissions errors if we know the repository is using rulesets, so non-admins can still get a score.
312312
queryData := new(branchData)
313313
if err := handler.graphClient.Query(handler.ctx, queryData, vars); err != nil {
314+
if strings.Contains(err.Error(), "resource not accessible by integration") {
315+
return nil, sce.WithMessage(sce.ErrScorecardInternal, "Branch protection check failed. Need to use a PAT.")
316+
}
314317
// always report errors which aren't token permission related
315318
if !isPermissionsError(err) {
316319
return nil, sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("githubv4.Query: %v", err))

0 commit comments

Comments
 (0)