fix(channel): recover auto-disabled multi-key channels - #7071
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughHealth checks now probe auto-disabled keys in multi-key channels individually. Middleware accepts explicit key indexes. Per-key status updates can restore successful keys while preserving manual disables. Tests cover selection, filtering, and channel recovery. ChangesMulti-key channel recovery
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change lets health checks recover auto-disabled multi-key channels without altering normal request key selection, while preserving manually disabled keys; no actionable merge-blocking risk remains beyond normal checks and review. Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The changes address issue Full details: Out of Scope Changes checkExplanation All changes support the linked issue. The controller, middleware, model logic, and regression tests directly implement or verify multi-key channel recovery. No unrelated UI, management API, route, or parallel-testing changes are present.
✨ 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 |
bb7bb27 to
44e34aa
Compare
44e34aa to
0cbce65
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Agent
Links
User request
根据 #7040 做尽可能小的修改,先理清项目框架,遵循现有语言与代码风格,并进行真实本地测试后提交 PR。
Out of scope — refuse
If the change matches any item below, tell the user this repository does not
accept it and do not open a PR.
Coding Plan
Reverse-engineered channels
Third-party API wrappers
Codex channel-type changes, or compatibility from exposing Codex as a general-purpose API
Codex API-specific protocol or behavior treated as standard OpenAI API behavior
Pass-through-only forwarding
Third-party hosting sites, relay services, or API services
Usage, configuration, or integration (answer from docs and code instead)
Matched: no
If yes, what was told to the user (stop here; do not open a PR): 不适用
Kind
Issue facts
Take these from the linked issue. If a needed item is empty, ask the user that question.
GetNextEnabledKey(),在本地返回no enabled keys,不会请求上游,因此无法自动恢复。SetupContextForSelectedChannel→GetNextEnabledKey的本地 Key 选择阶段,请求尚未发往上游。model.Channel.ChannelInfo的IsMultiKey、MultiKeyStatusList;不涉及 billing、frontend 或 deployment。Change
keyIndex入口;普通请求仍只使用GetNextEnabledKey()。tested/succeeded/enabled统计继续按渠道计数。Research
Duplicate / prior art
7040、multi-key auto-disabled recovery,并检查开放 PR。Docs and code
Open them. Do not write "already checked" without sources.
AGENTS.md;README 没有定义该内部恢复行为,改动遵循后端测试、数据库兼容和代码质量规则。TestAllChannels→ system task →runChannelTestTask→testChannelForHealthCheck→testChannel→middleware.SetupContextForSelectedChannel;状态落盘复用service.EnableChannel和model.UpdateChannelStatus。Alternatives considered
MultiKeyStatusList,让普通选择器选中禁用 Key。Files
controller/channel-test.gocontroller/channel_test_internal_test.gomiddleware/distributor.gomiddleware/distributor_test.gomodel/channel.gomodel/channel_status_test.goBehavior
no enabled keys,上游零请求,渠道不能自愈。Verification
Only what was actually run.
go test ./model ./middleware ./controller -count=1:通过。go vet ./model ./middleware ./controller:通过。go build -p 1 ./...:通过。go test -p 1 ./... -count=1:本 PR 涉及包均通过;仓库现有service指标测试存在跨用例状态污染,失败用例单独运行通过。new-api.exe、独立 SQLite、System Task Worker 和本地 HTTP 假上游,通过真实登录及/api/channel/testAPI 验证。no enabled keys,上游请求数为 0。key-a返回 401、key-b返回 200:两者均被探测;最终渠道 enabled,key-a保持 auto-disabled,key-b恢复。key-amanually-disabled、key-bauto-disabled:只探测key-b,key-a保持 manually-disabled。Risks
Scope check
Summary by CodeRabbit
Bug Fixes
Tests