mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
[PR #20590] [CLOSED] fix: code interpreter images fail with JSON serialization error #25692
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/20590
Author: @Classic298
Created: 1/11/2026
Status: ❌ Closed
Base:
dev← Head:fix-code-interpreter📝 Commits (2)
0acc927fix: code interpreter images fail with JSON serialization error on PostgreSQL096468aMerge branch 'dev' into fix-code-interpreter📊 Changes
3 files changed (+46 additions, -2 deletions)
View changed files
📝
backend/open_webui/routers/images.py(+5 -1)📝
backend/open_webui/utils/files.py(+4 -1)📝
backend/open_webui/utils/misc.py(+37 -0)📄 Description
fix: code interpreter images fail with JSON serialization error
When code interpreter generates matplotlib/plotly charts, the image upload
to the database fails on PostgreSQL with:
Root cause: The metadata dict passed from middleware to upload_image and
upload_audio contained non-JSON-serializable Python objects including:
These were passed through to upload_file_handler where they were stored
in the meta.data JSON field. PostgreSQL strictly enforces JSON validity,
causing the insert to fail.
Solution: Added sanitize_metadata helper function in utils/misc.py that
filters out:
The function recursively sanitizes nested dicts and lists while preserving
essential metadata like chat_id and message_id needed for file-to-chat linking.
Applied sanitization in:
Regression tested on SQLite:
Fixes #20561
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.