Repository navigation
Python: fix(ollama): reject non-image data content instead of sending it as an image - #8917
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits intoOct 1, 2026
Conversation
Leela Mahalakshmi (Leela0o5)
requested review from
SergeyMenshykh,
Tao Chen (TaoChenOSU),
Eduard van Valkenburg (eavanvalkenburg),
Giles Odigwe (giles17),
Jose Alvarez (jpalvarezl),
Evan Mattson (moonbox3),
Roger Barreto (rogerbarreto),
sophia-ramsey and
westey (westey-m)
as code owners
September 30, 2026 18:52
Leela Mahalakshmi (Leela0o5)
temporarily deployed
to
github-app-auth
September 30, 2026 18:52 — with
GitHub Actions
Inactive
Leela Mahalakshmi (Leela0o5)
temporarily deployed
to
github-app-auth
September 30, 2026 18:53 — with
GitHub Actions
Inactive
Contributor
Author
|
@microsoft-github-policy-service agree |
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Oct 1, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
OllamaChatClientchecked that any data content in a user message was an image, then sent all data contents in Ollama'simagesfield. A user message with an image plus a non-image attachment (e.g. a PDF) passed the check, and the PDF bytes were sent to Ollama as an image. Ollama's chat API has no document input, so this can never work and fails later with a confusing error.Description & Review Guide
_format_user_messagenow requires every data content to be an image (anytoall). Added a unit test with an image plus a PDF.ChatClientInvalidRequestException, matching how a message with only non-image data is already handled. Image-only messages are unchanged.Related Issue
Fixes #8916
Contribution Checklist