test(ai-review): pin isRateLimitError's 429-shape contract - #5506
test(ai-review): pin isRateLimitError's 429-shape contract#5506carlh7777 wants to merge 1 commit into
Conversation
Introduces a new test suite for the isRateLimitError function to ensure it correctly identifies rate limit errors (HTTP 429) across various provider error messages. The tests cover matching valid 429 errors, rejecting non-429 errors, and validating the function's behavior with non-Error values. This addition helps prevent future regressions in error handling related to rate limits.
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5506 +/- ##
=======================================
Coverage 94.75% 94.75%
=======================================
Files 564 564
Lines 44896 44896
Branches 14675 14675
=======================================
Hits 42541 42541
Misses 1621 1621
Partials 734 734
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Caution 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 🛑 Gittensory review result - reject/close recommendedReview updated: 2026-07-12 23:56:11 UTC
🛑 Suggested Action - Reject/Close Review summary Blockers
Nits — 5 non-blocking
Why this is blocked
📋 Copy for AI agents — paste into your coding agentFlagged checks (non-blocking)
Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
|
Gittensory is closing this pull request on the maintainer's behalf (No linked issue detected; AI reviewers agree on a likely critical defect: No issue is linked — the description leaves the 'Closes #' placeholder unfilled, and this repo requires every contributor PR to close or clearly link an eligible open issue.). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed. |
Summary
Adds a direct contract test for
isRateLimitError(src/services/ai-review.ts), the shared 429 short-circuit introduced in the recently-merged #5481 (#5385-sentry / GITTENSORY-K/8).That PR exported
isRateLimitErrorand wired it into five independent AI-calling retry loops —runWorkersOpinion+runDualAiTieBreakJudgeCall(services/ai-review.ts),review/planner.ts,services/ai-slop.ts, andservices/linked-issue-satisfaction-run.ts— each of which nowbreaks out of its same-model retry on a 429 instead of burning the remaining per-model budget on a rate-limit window that won't have cleared a few hundred ms later. The helper shipped with no test of its own, so a future tweak to its/_(?:http|error)_429$/matcher could silently regress the short-circuit across all five call sites at once.The suite pins the exact contract:
src/selfhost/ai.tsactually throws —ai_http_429,anthropic_http_429,claude_code_error_429,ai_embed_http_429;ai_http_400/500/503,claude_code_error_404) that a retry might legitimately clear;subscription_cli_timeout,codex_exit_1: …);$anchor (a longer status or trailing detail likeai_http_4291/ai_http_429: too many requestsis not a 429) and the_http/_errordelimiter (a bare429/http_429substring never trips it);falsefor any non-Errorvalue (theerror instanceof Errorguard).No production code changes.
Closes #
Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run typechecknpm run test:coverage— not applicable to coverage: this is a test-only change (nosrc/**lines), which Codecov ignores;npx vitest run test/unit/ai-review-rate-limit-error.test.tspasses (6/6), asserting behavior verified empirically against the live regex.npm run test:workers·build:mcp·test:mcp-pack·ui:*— N/A (no worker/MCP/UI/OpenAPI surface touched).If any required check was skipped, explain why:
Test-only change adding one
test/unit/**file; it touches nosrc/**, workflow, MCP, OpenAPI, or UI surface, so the build/UI/MCP checks are N/A and there are no coverable lines for Codecov.Safety
UI Evidence
N/A — no UI/frontend/docs changes.
Notes
/_(?:http|error)_429$/matcher before being written, so the suite documents the actual contract rather than an assumed one.