Repository navigation
fix(error-status): parse "Error: <status>" with no colon after the status - #64
Conversation
…atus
GitHub Copilot reports quota exhaustion as:
Error: 429 quota exceeded
That message fell between two existing patterns. The leading-bare-status
pattern accepts an "Error:" prefix but requires a colon AFTER the status,
matching "Error: 401: {...}". The "error <status>" pattern requires
whitespace directly after "error", so the colon in "Error:" defeats it.
With no status parsed, turn_end returns early and no rule can fire, so
Copilot quota exhaustion never triggered a fallback.
The new pattern is anchored and requires the literal word "error". That
matters: dropping the prefix requirement would also match prose such as
"429 tokens remaining in context window", which the existing tests
require to stay unmatched.
Also recognises a bare status followed by a quota noun, so
"429 quota exceeded" parses on its own. This relies on adjacency, so
"429 tokens left before the quota resets" still does not match.
npm run ci passes: 39 tests, up from 37.
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (9)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
…iei114#58) * feat(rules): match failure reasons such as context_length_exceeded Add an optional `reasons` field to fallback rules. When set, a rule only fires if the failure reason parsed from the provider error message is listed. Reasons come from quoted machine codes (for example "provider_error_code":"context_length_exceeded") or prose such as "exceeds this model's context length". This lets status 400 trigger a fallback for context-length overflow while other 400s stay errors. Also skip rules whose fallback target equals the failing model, so a broad provider rule can safely target a model inside that provider. Reason sets participate in shadowing analysis: unrestricted earlier rules shadow later reason-scoped rules, but rules with disjoint reason sets on the same scope are not reported as duplicates. * feat(fallback): cascade through chains while blocking circular loops Fallback targets can now fail and cascade onward via other matching rules (e.g. free -> kimi-k2.6 -> glm-5.3-flash) instead of surfacing the error. A per-run visited set blocks revisiting any model already used, so circular rules cannot ping-pong; re-applying the preselected fallback for an error attributed to the original model stays allowed (idempotent).
|
Thanks @tc3oliver — merged as 640f09e. The diagnosis was the useful part here: the two existing patterns each required something the other shape did not have, and keeping the One note for next time: you predicted the rebase against #58 in the PR body, and it landed exactly as you said — a single CHANGELOG conflict, code auto-merged. I resolved it on your branch and pushed the merge commit, so the credit and history stay with your PR. Nice work." |
Summary
Error: 429 quota exceeded, andparseStatusFromErrorMessagereturnsundefinedfor it.turn_endthen returns early, no rule can match, and the fallback never fires.Error:prefix but requires a colon after the status (Error: 401: {...}, added in fix: parse leading bare status codes in error messages #55). Theerror <status>pattern requires whitespace directly aftererror, so the colon inError:defeats it.error, and addsquotato the trailing-noun list so a bare429 quota exceededparses too.Observed in a real session (Pi 0.85.1,
github-copilotprovider):/model-fallback:statusshowedRules: 3,Config warnings: none, andstate.jsonwas never created —persistFailure()was never reached.Before / after:
Not broadening the match
The prefix requirement is deliberate. Dropping it would also match prose the existing tests require to stay unmatched:
The
quotanoun relies on adjacency for the same reason, so429 tokens left before the quota resetsstill does not match. Both cases are added as regression assertions.Note on #58
#58 also touches
lib/error-status.ts(addingreasons). The two changes are independent — this one only widens status extraction — but whichever lands second will need a trivial rebase.Testing
npm run ci— 39 tests pass, up from 37 onmainpi -e .On
pi -e .: the fix was validated by applying it to an installed 0.4.0 and re-runningparseStatusFromErrorMessageagainst the verbatim error string from the session above, which now yields429. A full interactive confirmation needs another Copilot quota exhaustion to reproduce, so I have not checked that box. Happy to follow up with it once the allowance next runs out.Checklist
Unreleasednpm pack --dry-run— unchanged, nodocs/files added or renamedSummary by CodeRabbit
New Features
Bug Fixes
Error: 429 quota exceeded.Documentation