{"record":{"id":"4d7849cf9685d2c3","repo":"router-for-me/CLIProxyAPI","slug":"token-refresh-failed-after-d-attempts-w","errorCode":null,"errorMessage":"token refresh failed after %d attempts: %w","messagePattern":"token refresh failed after (.+?) attempts: %w","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/claude/anthropic_auth.go","lineNumber":661,"sourceCode":"\t\t\tcase <-ctx.Done():\n\t\t\t\treturn nil, ctx.Err()\n\t\t\tcase <-time.After(time.Duration(attempt) * time.Second):\n\t\t\t}\n\t\t}\n\n\t\ttokenData, err := o.RefreshTokens(ctx, refreshToken)\n\t\tif err == nil {\n\t\t\treturn tokenData, nil\n\t\t}\n\n\t\tlastErr = err\n\t\tlog.Warnf(\"Token refresh attempt %d failed: %v\", attempt+1, err)\n\t\tif !isClaudeRefreshRetryable(err) {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn nil, fmt.Errorf(\"token refresh failed after %d attempts: %w\", maxRetries, lastErr)\n}\n\n// UpdateTokenStorage updates an existing token storage with new token data.\n// This method refreshes the token storage with newly obtained access and refresh tokens,\n// updating timestamps and expiration information.\n//\n// Parameters:\n//   - storage: The existing token storage to update\n//   - tokenData: The new token data to apply\nfunc (o *ClaudeAuth) UpdateTokenStorage(storage *ClaudeTokenStorage, tokenData *ClaudeTokenData) {\n\tstorage.AccessToken = tokenData.AccessToken\n\tstorage.RefreshToken = tokenData.RefreshToken\n\tstorage.LastRefresh = time.Now().Format(time.RFC3339)\n\tif tokenData.Email != \"\" {\n\t\tstorage.Email = tokenData.Email\n\t}\n\tif tokenData.AccountUUID != \"\" {\n\t\tstorage.AccountUUID = tokenData.AccountUUID","sourceCodeStart":643,"sourceCodeEnd":679,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/claude/anthropic_auth.go#L643-L679","documentation":"Error \"token refresh failed after %d attempts: %w\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/auth/claude/anthropic_auth.go:661 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the final wrapped error: re-authenticate if the refresh token was revoked.","Verify the token endpoint is reachable and retry after resolving the underlying failure."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}