diff --git a/pkg/providers/error_classifier.go b/pkg/providers/error_classifier.go index 89842f339..3b13a7f04 100644 --- a/pkg/providers/error_classifier.go +++ b/pkg/providers/error_classifier.go @@ -9,7 +9,7 @@ import ( // Common patterns in Go HTTP error messages var httpStatusPatterns = []*regexp.Regexp{ regexp.MustCompile(`status[:\s]+(\d{3})`), - regexp.MustCompile(`HTTP[/\s]+\d*\.?\d*\s+(\d{3})`), + regexp.MustCompile(`\b([3-5]\d{2})\b`), } // errorPattern defines a single pattern (string or regex) for error classification. @@ -204,7 +204,7 @@ func classifyByMessage(msg string) FailoverReason { } // extractHTTPStatus extracts an HTTP status code from an error message. -// Looks for patterns like "status: 429", "status 429", "HTTP 429", or standalone "429". +// Looks for patterns like "status: 429", "status 429", "HTTP/1.1 429", "HTTP 429", or standalone "429". func extractHTTPStatus(msg string) int { for _, p := range httpStatusPatterns { if m := p.FindStringSubmatch(msg); len(m) > 1 { diff --git a/pkg/providers/error_classifier_test.go b/pkg/providers/error_classifier_test.go index 865aea57a..82db7d31d 100644 --- a/pkg/providers/error_classifier_test.go +++ b/pkg/providers/error_classifier_test.go @@ -306,6 +306,7 @@ func TestExtractHTTPStatus(t *testing.T) { {"status: 429 rate limited", 429}, {"status 401 unauthorized", 401}, {"HTTP/1.1 502 Bad Gateway", 502}, + {"error 429", 429}, {"no status code here", 0}, {"random number 12345", 0}, }