Repository navigation
fix(settings): diagnose CodeBuddy discovery and test live connections - #1534
Robert0622 wants to merge 4 commits into
Conversation
|
CR @ 436436a(19:00 定时评审) 结论:主体修复有效,本机部署实测通过;发现 1 个 P3(不阻塞合入,建议修):测试连接时,模型 ID 写错或在当前网络环境不可用,提示的是「AI 助手生成中断,未返回完整回答,请重试」,会让人以为是偶发故障、去反复重试。 P3:模型 ID 无效时,测试连接给出误导性提示
实测环境本机 MariaDB + 源码构建,同时部署 main
错误 Key 的报错文本、响应体里都没有回显 Key;页面上没有 JS 错误。 截图main 测试连接: 自动化
其他小点(不阻塞)
(评论人这个 token 是 PR 作者本人,GitHub 不允许给自己的 PR 点 Approve,所以这里只评论。) |
crispinhu27
left a comment
There was a problem hiding this comment.
审查结论:APPROVE(head 436436ae,base 697b63c8)
初审。审查范围:assistant_models.go / cli_models_probe.go 的 CodeBuddy 目录诊断与「测试连接」、新增的两个 Go 测试、web/app/workbench.js 的 probeCredentialCatalog、webtest/tests/runner-codebuddy-environment.test.mjs。
实际执行的验证(全部在 head 436436ae 上)
go build ./...、go vet ./internal/httpapi/通过;go test ./internal/httpapi/ -run 'Model|Probe|CodeBuddy'通过。- 全量
go test ./internal/httpapi/有 17 个失败,全部在基线697b63c8上逐项复现(缺bwrap、Chromium 的 SSH/终端/浏览器类用例),与本 PR 无关。 webtest全量 396/396 通过;直接跑runner-codebuddy-environment.test.mjs8/8 通过。- 凭据不泄露:CLI 把 API Key 打到 stderr(退出码非 0、输出不可解析两种路径)时返回的都是固定文案,诊断日志里 key 显示为
<redacted>。 - 兼容性:
connectOnly/model只在engine==codebuddy && baseURL==""分支读取,其他引擎与自定义 Base URL 路径行为不变。 - 连接测试超时:父 ctx 300ms 截止时约 301ms 返回「测试 CodeBuddy 连接超时」,
errors.Is(err, context.DeadlineExceeded)正确命中。
一处已确认但非阻塞的问题(P3,建议后续修)
进程退出后仍有子进程占着 stdout 时,已完整输出的模型列表会被当成「超时」丢掉(internal/httpapi/assistant_models.go:120 的 cmd.WaitDelay 与 :126 的 errors.Is(err, exec.ErrWaitDelay) 分支)。
- 触发:
codebuddy --help已打印完整列表并退出,但它派生的后台子进程仍持有 stdout 且存活超过 1s。 - 预期:照常解析已读到的输出(仓库内
internal/runtime/process.go:99-101就是这么处理ErrWaitDelay的)。实际:readCodeBuddyModels返回「获取 CodeBuddy 模型列表超时」,discoverCodeBuddyModels也随之返回空。 - 复现(临时 Go 测试,已删除未推送):假 CLI 为
( /bin/sleep 3 ) & printf 'Currently supported: (fixture-model)\n'。- head:
models=[] err=获取 CodeBuddy 模型列表超时… elapsed=1.001s - 基线
697b63c8:models=[fixture-model] elapsed=3.001s
- head:
- 建议:命中
exec.ErrWaitDelay时不要直接判超时,改用已拿到的out继续解析;只有ctx.Err()==DeadlineExceeded才报超时。真实 CLI 是否会产生这种子进程未验证,故不阻塞。
未验证的怀疑(不作为结论)
- 连接测试默认模型写死
deepseek-v4.1-flash,三个官方站点是否有该模型需真实 key 才能确认。 - 前端用目录里第一个模型发起连接测试,该模型在当前环境不可用时即使 key 有效也会显示失败。这两项都需要真实 CodeBuddy 服务,本次未验证。
…sult
A mistyped or unavailable model ID makes CodeBuddy stream the reason only in
an assistant text block ("400 model [x] service info not found") and finish
with an empty result payload, so the connection test classified it as a
generic MISSING_RESULT and told the user to retry. Keep the last assistant
text and pass it to the failure classifier, accept the bracketed model form,
and have the connection test name the model it could not use.
Co-Authored-By: Claude Code <noreply@anthropic.com>
|
已按上轮 P3 修复并实测,新 head 改动(4 文件 +78/−1)
部署实测(本机 MariaDB 11.8 + 源码构建 head
验证: loopforge-pr-review:eeaa38e1a03c082f37942de6315a711f3dd7bfff |
… error Appending every narration block changed the error text main's Claude recovery path asserts, so only model/auth rejections are appended. Co-Authored-By: Claude Code <noreply@anthropic.com>









What changed
Scope
Compatibility
The existing model probe accepts optional
connectOnlyandmodelrequest fields. Requests without those fields still perform model discovery.Validation
deepseek-v4.1-flash: domestic catalog returned 20 models and Test connection succeeded. Forced malformed CLI help produced the specific error and retry control. A manually entered model still passed Test connection and returnedPONGin chat. The iOA authentication failure appeared in Test connection while the catalog could still load.Safety