[PR #21503] [CLOSED] fix: include chat attachment images in OpenAI payload #80980

Closed
opened 2026-05-13 15:17:33 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21503
Author: @Plutarch01
Created: 2/17/2026
Status: Closed

Base: mainHead: fix/chat-files-image-forwarding


📝 Commits (1)

  • 4f1237a fix: forward chat attachment images in OpenAI payload

📊 Changes

3 files changed (+232 additions, -0 deletions)

View changed files

backend/open_webui/test/util/test_middleware_images.py (+124 -0)
backend/open_webui/utils/chat_image_payload.py (+95 -0)
📝 backend/open_webui/utils/middleware.py (+13 -0)

📄 Description

Summary

  • add append_chat_file_images_to_user_messages to convert DB-backed chat files image attachments into OpenAI image_url message parts
  • invoke this conversion in process_chat_payload after URL->base64 normalization so image attachments survive OpenAI-compatible forwarding
  • keep conversion safe by skipping messages that already contain image_url parts and ignoring non-image attachments
  • add regression tests covering image injection, duplicate-image skip, non-image ignore, and no-parent no-op paths

Why

OpenWebUI stores pasted/uploaded chat images under message files, but the outgoing OpenAI-compatible payload may only include text content when those files are not lifted into messages[].content parts. This causes downstream gateways/providers to miss image inputs even though the UI shows an attachment.

Testing

  • python -m py_compile backend/open_webui/utils/middleware.py backend/open_webui/utils/chat_image_payload.py backend/open_webui/test/util/test_middleware_images.py
  • python -c \"import sys,pytest; sys.path.insert(0,'backend'); raise SystemExit(pytest.main(['backend/open_webui/test/util/test_middleware_images.py']))\"

🔄 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/open-webui/open-webui/pull/21503 **Author:** [@Plutarch01](https://github.com/Plutarch01) **Created:** 2/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/chat-files-image-forwarding` --- ### 📝 Commits (1) - [`4f1237a`](https://github.com/open-webui/open-webui/commit/4f1237acd62499323beac5f03152be22eeecf19a) fix: forward chat attachment images in OpenAI payload ### 📊 Changes **3 files changed** (+232 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `backend/open_webui/test/util/test_middleware_images.py` (+124 -0) ➕ `backend/open_webui/utils/chat_image_payload.py` (+95 -0) 📝 `backend/open_webui/utils/middleware.py` (+13 -0) </details> ### 📄 Description ## Summary - add `append_chat_file_images_to_user_messages` to convert DB-backed chat `files` image attachments into OpenAI `image_url` message parts - invoke this conversion in `process_chat_payload` after URL->base64 normalization so image attachments survive OpenAI-compatible forwarding - keep conversion safe by skipping messages that already contain `image_url` parts and ignoring non-image attachments - add regression tests covering image injection, duplicate-image skip, non-image ignore, and no-parent no-op paths ## Why OpenWebUI stores pasted/uploaded chat images under message `files`, but the outgoing OpenAI-compatible payload may only include text content when those files are not lifted into `messages[].content` parts. This causes downstream gateways/providers to miss image inputs even though the UI shows an attachment. ## Testing - `python -m py_compile backend/open_webui/utils/middleware.py backend/open_webui/utils/chat_image_payload.py backend/open_webui/test/util/test_middleware_images.py` - `python -c \"import sys,pytest; sys.path.insert(0,'backend'); raise SystemExit(pytest.main(['backend/open_webui/test/util/test_middleware_images.py']))\"` --- <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-05-13 15:17:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#80980