fix(routing): fall back past HTTP 402 payment-required providers - #16
Merged
Merged
Conversation
Cerebras now answers 402 "Payment required to access this resource" on chat completions for every model until the account adds a payment method, while GET /models still lists them. classifyProviderError had no 402 rule, so it fell to 'other' (retryable: false): model:auto returned a 502 instead of trying the next model, and nothing was recorded, so the next request picked Cerebras again. 402 is a billing state of the account, so it joins the account-denial branch: retryable, model not quarantined, credential benched for 24h across the platform. Matched before the rate-limit branch because some 402 bodies (Chutes) also say "quota". Includes the rebuilt server/dist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In the production Playground, Auto (chat route) returned a 502 on every message:
Cerebras now blocks chat completions for all models until the account has a payment method, while
GET /v1/modelsstill lists them.Root cause
classifyProviderErrorhad no rule for HTTP 402, so the error fell toother(retryable: false):recordTerminalProviderFailurerecords nothing forother, so the next request picked Cerebras again, forever.Same bug class as the 410 fix in #8: an unclassified status code ends the fallback chain.
Fix
402 / "payment required" joins the existing account-denial branch in
server/src/services/provider-errors.ts:retryable: true, so auto-route falls through to the next model;skipModel: false, so the model is not quarantined (the account is the problem);It is matched with
/\b402\b/(no false positives on numbers like 4020) and placed before the rate-limit branch, because some 402 bodies (Chutes) also say "quota".Tests
account-denial-cooldown.test.tsproxy-model-hardening.test.ts: Cerebras 402 → Groq serves; the second request does not call Cerebras again; the model is not blocked. Returns 502 without the fix (verified by stashing the change).tscclean;server/distrebuilt (provider-errors outputs only).After merge
git fetch origin && git reset --hard origin/main && systemctl restart llm-hub).🤖 Generated with Claude Code