[PR #14066] openai: Improve error messages in FromChatRequest for better debugging #14494

Open
opened 2026-04-13 00:55:52 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14066
Author: @mahanadh
Created: 2/4/2026
Status: 🔄 Open

Base: mainHead: tech/improve-error-debugging


📝 Commits (1)

  • 7a797dc openai: improve error messages in FromChatRequest for better debugging

📊 Changes

2 files changed (+97 additions, -5 deletions)

View changed files

📝 openai/openai.go (+5 -5)
📝 openai/openai_test.go (+92 -0)

📄 Description

Summary

This PR improves the developer experience when using Ollama's OpenAI-compatible API by providing specific, actionable error messages instead of generic ones.

Problem

The FromChatRequest function in the OpenAI compatibility layer returned the same generic "invalid message format" error for 5 different failure scenarios. This has made it difficult for users to debug issues with their API requests.

Solution

Replaced generic error messages with specific ones that include:

  • The field that failed validation
  • The expected type/format
  • The actual type that was received

Testing

Added comprehensive test cases in TestFromChatRequest_InvalidMessageContent covering all 5 error scenarios.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

🔄 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/14066 **Author:** [@mahanadh](https://github.com/mahanadh) **Created:** 2/4/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `tech/improve-error-debugging` --- ### 📝 Commits (1) - [`7a797dc`](https://github.com/ollama/ollama/commit/7a797dc47387317603f64fd67cb1acd9c41be2ab) openai: improve error messages in FromChatRequest for better debugging ### 📊 Changes **2 files changed** (+97 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `openai/openai.go` (+5 -5) 📝 `openai/openai_test.go` (+92 -0) </details> ### 📄 Description ## Summary This PR improves the developer experience when using Ollama's OpenAI-compatible API by providing specific, actionable error messages instead of generic ones. ## Problem The `FromChatRequest` function in the OpenAI compatibility layer returned the same generic "invalid message format" error for 5 different failure scenarios. This has made it difficult for users to debug issues with their API requests. ## Solution Replaced generic error messages with specific ones that include: - The field that failed validation - The expected type/format - The actual type that was received ## Testing Added comprehensive test cases in `TestFromChatRequest_InvalidMessageContent` covering all 5 error scenarios. ## Type of Change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) --- <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-13 00:55:52 -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#14494