MCPcopy Create free account
hub / github.com/github/gh-aw / IsAuthError

Function IsAuthError

pkg/gitutil/gitutil.go:32–47  ·  view source on GitHub ↗

IsAuthError checks if an error message indicates an authentication issue. This is used to detect when GitHub API calls fail due to missing or invalid credentials.

(errMsg string)

Source from the content-addressed store, hash-verified

30// IsAuthError checks if an error message indicates an authentication issue.
31// This is used to detect when GitHub API calls fail due to missing or invalid credentials.
32func IsAuthError(errMsg string) bool {
33 gitutilLog.Printf("Checking if error is auth-related: %s", errMsg)
34 lowerMsg := strings.ToLower(errMsg)
35 isAuth := strings.Contains(lowerMsg, "gh_token") ||
36 strings.Contains(lowerMsg, "github_token") ||
37 strings.Contains(lowerMsg, "authentication") ||
38 strings.Contains(lowerMsg, "not logged into") ||
39 strings.Contains(lowerMsg, "unauthorized") ||
40 strings.Contains(lowerMsg, "forbidden") ||
41 strings.Contains(lowerMsg, "permission denied") ||
42 strings.Contains(lowerMsg, "saml enforcement")
43 if isAuth {
44 gitutilLog.Print("Detected authentication error")
45 }
46 return isAuth
47}
48
49// IsHexString checks if a string contains only hexadecimal characters.
50// This is used to validate Git commit SHAs and other hexadecimal identifiers.

Callers 13

resolveRefToSHAFunction · 0.92
listWorkflowFilesForHostFunction · 0.92
listDirAllFilesForHostFunction · 0.92
listDirSubdirsForHostFunction · 0.92
getRepoDefaultBranchFunction · 0.92
getLatestBranchCommitSHAFunction · 0.92
downloadWorkflowContentFunction · 0.92

Calls 3

ToLowerMethod · 0.80
PrintMethod · 0.80
PrintfMethod · 0.45

Tested by 2

TestIsAuthErrorFunction · 0.68