Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
server/internal/registry: make pull send errors with Error field (#10326)
Blake Mizerany4e535e618846
diff --git a/server/internal/registry/server.go b/server/internal/registry/server.goindex bd5f7dcd5..af26fe1d5 100644--- a/server/internal/registry/server.go+++ b/server/internal/registry/server.go@@ -244,6 +244,7 @@ func (s *Local) handleDelete(_ http.ResponseWriter, r *http.Request) error {}type progressUpdateJSON struct {+ Error string `json:"error,omitempty,omitzero"`Status string `json:"status,omitempty,omitzero"`Digest blob.Digest `json:"digest,omitempty,omitzero"`Total int64 `json:"total,omitempty,omitzero"`@@ -348,14 +349,15 @@ func (s *Local) handlePull(w http.ResponseWriter, r *http.Request) error {case err := <-done:flushProgress()if err != nil {- var status stringif errors.Is(err, ollama.ErrModelNotFound) {- status = fmt.Sprintf("error: model %q not found", p.model())+ return &serverError{+ Status: 404,+ Code: "not_found",+ Message: fmt.Sprintf("model %q not found", p.model()),+ }} else {- status = fmt.Sprintf("error: %v", err)+ return err}- enc.Encode(progressUpdateJSON{Status: status})- return nil}// Emulate old client pull progress (for now):diff --git a/server/internal/registry/server_test.go b/server/internal/registry/server_test.goindex 61b57f114..15d8d828a 100644--- a/server/internal/registry/server_test.go+++ b/server/internal/registry/server_test.go@@ -221,7 +221,7 @@ func TestServerPull(t *testing.T) {got = s.send(t, "POST", "/api/pull", `{"model": "unknown"}`)checkResponse(got, `- {"status":"error: model \"unknown\" not found"}+ {"code":"not_found","error":"model \"unknown\" not found"}`)got = s.send(t, "DELETE", "/api/pull", `{"model": "smol"}`)@@ -235,7 +235,7 @@ func TestServerPull(t *testing.T) {got = s.send(t, "POST", "/api/pull", `{"model": "://"}`)checkResponse(got, `- {"status":"error: invalid or missing name: \"\""}+ {"code":"bad_request","error":"invalid or missing name: \"\""}`)// Non-streaming pulls