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)
| 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. |
| 32 | func 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. |