Skip to content

Commit 8485131

Browse files
committed
modelerrors: remove numeric status-code patterns from string matching
ExtractHTTPStatusCode + IsRetryableStatusCode already handle numeric status codes (500, 502, 429, 401, etc.) via regex with word boundaries. Having the same codes as bare substrings in the retryable/non-retryable pattern lists caused false positives (e.g., "processed 500 items" would match). Remove the numeric patterns and keep only the descriptive text patterns. Assisted-By: docker-agent
1 parent da45428 commit 8485131

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

pkg/modelerrors/modelerrors.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,12 @@ func IsRetryableModelError(err error) bool {
277277
// Fall back to message-pattern matching for errors without structured status codes
278278
errMsg := strings.ToLower(err.Error())
279279

280-
// Retryable patterns (5xx, timeout, network issues)
281-
// NOTE: 429 is explicitly NOT in this list - we skip to next model for rate limits
280+
// Retryable patterns (timeout, network issues)
281+
// NOTE: Numeric status codes (500, 502, etc.) are already handled by
282+
// ExtractHTTPStatusCode + IsRetryableStatusCode above; they are not
283+
// duplicated here to avoid false positives on arbitrary numbers in
284+
// error messages (e.g., "processed 500 items").
282285
retryablePatterns := []string{
283-
"500", // Internal server error
284-
"502", // Bad gateway
285-
"503", // Service unavailable
286-
"504", // Gateway timeout
287-
"408", // Request timeout
288286
"timeout", // Generic timeout
289287
"connection reset", // Connection reset
290288
"connection refused", // Connection refused
@@ -311,17 +309,14 @@ func IsRetryableModelError(err error) bool {
311309
}
312310

313311
// Non-retryable patterns (skip to next model immediately)
312+
// NOTE: Numeric status codes (429, 401, etc.) are already handled by
313+
// ExtractHTTPStatusCode above; they are not duplicated here.
314314
nonRetryablePatterns := []string{
315-
"429", // Rate limit - skip to next model
316315
"rate limit", // Rate limit message
317316
"too many requests", // Rate limit message
318317
"throttl", // Throttling (rate limiting)
319318
"quota", // Quota exceeded
320319
"capacity", // Capacity issues (often rate-limit related)
321-
"401", // Unauthorized
322-
"403", // Forbidden
323-
"404", // Not found
324-
"400", // Bad request
325320
"invalid", // Invalid request
326321
"unauthorized", // Auth error
327322
"authentication", // Auth error

0 commit comments

Comments
 (0)