Skip to content

fix: auto-disable channels on 5xx errors - #5073

Closed
zhumengstar wants to merge 1 commit into
QuantumNous:mainfrom
zhumengstar:auto-disable-5xx-channels
Closed

fix: auto-disable channels on 5xx errors#5073
zhumengstar wants to merge 1 commit into
QuantumNous:mainfrom
zhumengstar:auto-disable-5xx-channels

Conversation

@zhumengstar

@zhumengstar zhumengstar commented May 23, 2026

Copy link
Copy Markdown

Summary

  • Include 500-599 in the default automatic channel-disable status codes so failed 5xx channels are removed from future selection, not only retried within the current request.
  • Add regression coverage that default retry includes 502 and default auto-disable includes 500/502/599 while excluding client-side 400.

Test Plan

  • go test ./setting/operation_setting ./service -run "TestShould|TestSelectFailover" -count=1

Production notes

  • Runtime options should also include AutomaticDisableStatusCodes=401,500-599 and AutomaticRetryStatusCodes=100-199,300-399,401-407,409-499,500-503,505-523,525-599.

Summary by CodeRabbit

  • Bug Fixes
    • Expanded automatic error handling to disable operations when encountering server errors (5xx status codes) alongside existing 401 error behavior.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 087e2222-06e2-45a2-88cf-c7e2671874b1

📥 Commits

Reviewing files that changed from the base of the PR and between ebbe315 and af86538.

📒 Files selected for processing (2)
  • setting/operation_setting/status_code_ranges.go
  • setting/operation_setting/status_code_ranges_test.go

Walkthrough

The PR expands the default automatic disable behavior for HTTP status codes by adding the full 5xx range (500–599) to the existing 401 Unauthorized default. The default variable, test assertions for retry behavior, and a new dedicated test for disable behavior are updated together to reflect this policy change.

Changes

Server error auto-disable default expansion

Layer / File(s) Summary
Expand default disable range for 5xx status codes
setting/operation_setting/status_code_ranges.go, setting/operation_setting/status_code_ranges_test.go
The AutomaticDisableStatusCodeRanges default is extended to include 500–599 alongside 401, and test coverage is expanded to assert 5xx disable behavior and verify that non-5xx codes (e.g., 400) are not disabled by default.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • QuantumNous/new-api#2647: The original PR that introduced AutomaticDisableStatusCodeRanges; this PR extends its default range to cover all 5xx status codes.

Poem

🐰 A bunny hopped through status codes with glee,
Adding 500-599 to the default policy,
Server errors now disabled, no retry in sight,
Four-oh-one joined by five-hundreds, oh what a delight! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: updating auto-disable behavior to include 5xx HTTP status codes for channels.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zhumengstar
zhumengstar deleted the auto-disable-5xx-channels branch June 26, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants