[PR #14785] fix: handle error from json.Marshal in streaming response #25375

Open
opened 2026-04-19 18:10:54 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14785
Author: @LincolnBurrows2017
Created: 3/11/2026
Status: 🔄 Open

Base: mainHead: fix-json-marshal-error


📝 Commits (2)

  • 3506ec9 fix: handle error from json.Marshal in streaming response
  • 5179825 fix: use slog attributes directly instead of fmt.Sprintf

📊 Changes

2 files changed (+7 additions, -3 deletions)

View changed files

📝 llm/server.go (+2 -2)
📝 server/routes.go (+5 -1)

📄 Description

Description

The error from json.Marshal was being ignored at server/routes.go:2758, which could cause nil pointer issues when the marshal fails. This fix properly handles the error and logs it.

Changes

  • Handle error from json.Marshal in streaming response
  • Log error when marshaling fails

Testing

The fix ensures that if json.Marshal fails, the error is properly handled instead of being silently ignored.


🔄 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/14785 **Author:** [@LincolnBurrows2017](https://github.com/LincolnBurrows2017) **Created:** 3/11/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-json-marshal-error` --- ### 📝 Commits (2) - [`3506ec9`](https://github.com/ollama/ollama/commit/3506ec9e97996cb4140e82e3a399a31648a9abef) fix: handle error from json.Marshal in streaming response - [`5179825`](https://github.com/ollama/ollama/commit/517982519b090ca1b8bcd8380b52a4f62f614d38) fix: use slog attributes directly instead of fmt.Sprintf ### 📊 Changes **2 files changed** (+7 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `llm/server.go` (+2 -2) 📝 `server/routes.go` (+5 -1) </details> ### 📄 Description ## Description The error from `json.Marshal` was being ignored at server/routes.go:2758, which could cause nil pointer issues when the marshal fails. This fix properly handles the error and logs it. ## Changes - Handle error from json.Marshal in streaming response - Log error when marshaling fails ## Testing The fix ensures that if json.Marshal fails, the error is properly handled instead of being silently ignored. --- <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-19 18:10:54 -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#25375