mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-27 08:14:33 +08:00
cb4ecd3951
Two related changes to make per-provider failover behave correctly. 1. Bucket UpstreamError by status code in categorize_proxy_error. The old "every UpstreamError is Retryable" rule meant a malformed client request (400 / 422) would be replayed against every provider in the queue: errors amplified N-fold, the circuit breaker accrued unwarranted failure counts, and quota was burned. Now 400 / 405 / 406 / 413 / 414 / 415 / 422 / 501 are NonRetryable since the request itself is wrong and no provider will accept it. 401 / 403 / 404 / 408 / 409 / 429 / 451 and all 5xx remain Retryable because the next provider may carry a different key, quota, region, or model mapping. 2. Make the rectifier-retry path participate in failover. Both the signature (RECT-003) and budget (RECT-012) rectifier branches used to "return Err(...)" after the retry failed, short-circuiting the per-provider loop. A provider-side failure (5xx / Timeout / ForwardFailed) now records the circuit breaker, accumulates into last_error / last_provider, and "continue"s to the next provider — matching the normal Retryable arm. Client-side failures still return immediately since a different provider cannot fix a malformed payload.