mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[PR #20238] [CLOSED] fix: image editing with uploaded images after file storage refactor #25514
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/20238
Author: @Classic298
Created: 12/29/2025
Status: ❌ Closed
Base:
dev← Head:image-edits📝 Commits (10+)
2ec1215Add standalone prune script with full prune.py functionality9455912Complete modular prune system with interactive UI and comprehensive testingd5442a6Add validation test script for prune systema5b7091Add Milvus and Milvus Multitenancy vector database cleaners64d0b60Update documentation to reflect Milvus vector database supportaa95fa7Add 100% vector database coverage for Milvus multitenancy cleanup61bd9a3Fix Milvus API usage: use utility.drop_collection and add collection.flush()cf356ffAdd pagination for Milvus multitenancy to handle >16k resources348c128Fix CRITICAL pagination bug: replace offset with query_iterator for Milvus multitenancyfe6783cMerge pull request #19030 from open-webui/dev📊 Changes
17 files changed (+6516 additions, -3 deletions)
View changed files
📝
backend/open_webui/models/channels.py(+129 -0)📝
backend/open_webui/routers/audio.py(+1 -1)📝
backend/open_webui/routers/files.py(+1 -1)📝
backend/open_webui/routers/images.py(+21 -0)📝
backend/open_webui/utils/middleware.py(+5 -1)➕
prune/README.md(+502 -0)➕
prune/prune.py(+177 -0)➕
prune/prune_cli_interactive.py(+825 -0)➕
prune/prune_core.py(+1805 -0)➕
prune/prune_imports.py(+185 -0)➕
prune/prune_models.py(+116 -0)➕
prune/prune_operations.py(+644 -0)➕
prune/requirements.txt(+24 -0)➕
prune/run_prune.sh(+95 -0)➕
prune/standalone_prune.py(+826 -0)➕
prune/test_prune.py(+899 -0)➕
prune/validate_structure.py(+261 -0)📄 Description
Description
This PR fixes image editing functionality that broke after the v0.42/v0.43 refactoring which changed how images are stored in chats. Previously, images were stored as base64 data directly in the chat JSON. After the refactor, images are stored as Files in the database and referenced in the chat JSON as URLs (file IDs) for page loading speedup and caching benefits.
This change inadvertently broke image editing because the backend code was not updated to handle the new image storage format.
Root Cause Analysis
Bug 1: get_images_from_messages only checked type == "image"
Location: backend/open_webui/utils/middleware.py
The get_images_from_messages function extracts images from chat messages to determine whether to trigger image editing vs image generation. It only checked for
file.get("type") == "image".However, when images are uploaded through the file upload API (non-temporary chats), they are stored with:
This caused uploaded images to be completely ignored, resulting in the image generation path being taken instead of image editing.
Note: The frontend already correctly handles both cases in Chat.svelte:
Bug 2: load_url_image didn't handle raw file IDs
Location: backend/open_webui/routers/images.py
The load_url_image function in the image_edits endpoint converts image URLs to base64 data before sending to the image editing API. It handled:
However, when an image is uploaded via the file upload API, the frontend sets file.url to just the file ID (e.g., abc123-def456-...), not a full URL path like /api/v1/files/{id}/content. This caused the function to return the raw file ID unchanged, which is not valid image data for the editing API.
Changes Made
1. backend/open_webui/utils/middleware.py
Updated get_images_from_messages() to also check for content_type starting with 'image/':
Before
if file.get("type") == "image":After
2. backend/open_webui/routers/images.py
Updated load_url_image() to handle raw file IDs by attempting to retrieve the file content:
How to Test
Additional Notes
Fixes #20237
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.