feat(auth): improve unauthorized error handling for refresh and auto-refresh

- Added `isUnauthorizedError` and `hasUnauthorizedAuthFailure` to classify and handle unauthorized errors.
- Introduced `refreshErrorFromError` to map errors to standardized unauthorized responses.
- Modified refresh logic to stop auto-refresh retries for unauthorized errors.
- Updated tests to verify unauthorized error handling and refresh retry prevention.
This commit is contained in:
Luis Pater
2026-05-13 02:59:46 +08:00
parent bd8c05a830
commit 6bfcb0ce79
5 changed files with 131 additions and 3 deletions
+3
View File
@@ -339,6 +339,9 @@ func nextRefreshCheckAt(now time.Time, auth *Auth, interval time.Duration) (time
if auth == nil {
return time.Time{}, false
}
if hasUnauthorizedAuthFailure(auth) {
return time.Time{}, false
}
accountType, _ := auth.AccountInfo()
if accountType == "api_key" {