[PR #14705] server: use error wrapping and check json.Marshal #46045

Open
opened 2026-04-25 01:36:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14705
Author: @alvinttang
Created: 3/8/2026
Status: 🔄 Open

Base: mainHead: fix/error-handling-improvements


📝 Commits (1)

  • e100d99 server: use %w for error wrapping and check json.Marshal error

📊 Changes

6 files changed (+12 additions, -8 deletions)

View changed files

📝 server/auth.go (+1 -1)
📝 server/images.go (+2 -2)
📝 server/internal/client/ollama/registry.go (+2 -2)
📝 server/quantization.go (+1 -1)
📝 server/routes.go (+5 -1)
📝 server/sched.go (+1 -1)

📄 Description

Summary

  • Replace %v and %s with %w in fmt.Errorf calls across server/ that wrap errors, enabling callers to use errors.Is/errors.As for programmatic error inspection.
  • Add missing error check for json.Marshal in the image generate streaming path (server/routes.go), which previously discarded the error with _.

Files changed

  • server/auth.go - wrap io.ReadAll error with %w
  • server/images.go - wrap pullModelManifest and HTTP response read errors with %w
  • server/internal/client/ollama/registry.go - wrap strconv.ParseInt errors with %w in chunk parsing
  • server/quantization.go - wrap tensor read error with %w
  • server/sched.go - wrap model load error with %w to preserve errors.Is chain
  • server/routes.go - check json.Marshal error in handleImageGenerate streaming path

Test plan

  • Verify go build ./... passes
  • Verify go vet ./... passes
  • Existing tests continue to pass (no behavioral change, only error chain preservation)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/14705 **Author:** [@alvinttang](https://github.com/alvinttang) **Created:** 3/8/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/error-handling-improvements` --- ### 📝 Commits (1) - [`e100d99`](https://github.com/ollama/ollama/commit/e100d99054ba11747bef574c8b43c4ad61074e9c) server: use %w for error wrapping and check json.Marshal error ### 📊 Changes **6 files changed** (+12 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `server/auth.go` (+1 -1) 📝 `server/images.go` (+2 -2) 📝 `server/internal/client/ollama/registry.go` (+2 -2) 📝 `server/quantization.go` (+1 -1) 📝 `server/routes.go` (+5 -1) 📝 `server/sched.go` (+1 -1) </details> ### 📄 Description ## Summary - Replace %v and %s with %w in fmt.Errorf calls across server/ that wrap errors, enabling callers to use errors.Is/errors.As for programmatic error inspection. - Add missing error check for json.Marshal in the image generate streaming path (server/routes.go), which previously discarded the error with _. ## Files changed - server/auth.go - wrap io.ReadAll error with %w - server/images.go - wrap pullModelManifest and HTTP response read errors with %w - server/internal/client/ollama/registry.go - wrap strconv.ParseInt errors with %w in chunk parsing - server/quantization.go - wrap tensor read error with %w - server/sched.go - wrap model load error with %w to preserve errors.Is chain - server/routes.go - check json.Marshal error in handleImageGenerate streaming path ## Test plan - [ ] Verify go build ./... passes - [ ] Verify go vet ./... passes - [ ] Existing tests continue to pass (no behavioral change, only error chain preservation) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-25 01:36:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#46045