Report a failed connection to Ollama as server_unreachable, not timeout

未关闭 适合新手
#73 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
86/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go, ollama
领域
backend, cli

调研方向

阅读 internal/ollama/ollama.go 以及 internal/ollama 下使用 httptest 的现有测试。检查 Chat 如何对超时错误进行分类,然后添加测试,分别覆盖拨号超时以及服务器接受连接但不响应的情况;拨号测试应在一秒内完成。完成标准是这两种情况分别返回与 ErrUnreachable 和 ErrTimeout 匹配的错误,并且 make check 通过。

由索引模型根据 Issue 内容生成。

描述

bench good first issue

What

When the Ollama host is down or unreachable, the TCP connection never opend and go will give up. MetCode reports this as "timeout" yet this is not specific enough for our case. We should report this as server_unreachable instead.

Where

The cause is in internal/ollama/ollama.go, in Chat: any net.Error with Timeout() == true becomes ErrTimeout, including a failed dial.

Fix

Before the Timeout() check, detect a failed dial and return ErrUnreachable instead. A dial failure is a *net.OpError with Op == "dial" (use errors.As).

Done when

  • A request that cannot connect returns an error that errors.Is(err, ollama.ErrUnreachable) accepts, even when the dial timed out.
  • A server that accepts the connection but never answers still returns ErrTimeout.
  • There is a test for each case. internal/ollama tests already fake servers with httptest. For the dial case, a listener that accepts nothing, or a short Client timeout against a non-routable address, works. Keep the test under a second.
  • make check passes.
主要语言
Go
星标
1
派生
2
平均合并
12 小时 55 分钟
30 天内合并 PR
18

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Edwin-metcalf/MetCode 的其他 Issue

查看 Edwin-metcalf/MetCode 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。