mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
[GH-ISSUE #20561] issue: [Bug] Code interpreter images fail to render - "Object of type function is not JSON serializable" in file upload (v0.7.1/v0.7.2) #57890
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?
Originally created by @4republic on GitHub (Jan 10, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/20561
Check Existing Issues
Installation Method
Docker
Open WebUI Version
v0.7.2 (also confirmed in v0.7.1)
Ollama Version (if applicable)
N/A (issue occurs with OpenAI-compatible APIs via LiteLLM)
Operating System
Win 11 Docker container WSL2
Browser (if applicable)
No response
Confirmation
README.md.Expected Behavior
When code interpreter generates a matplotlib/plotly chart, the image should be saved to the database and rendered inline in the chat as a visible image.
Actual Behavior
Code interpreter successfully generates the image, but the file upload to the database fails with a JSON serialization error. Instead of a rendered image, the raw base64 string is dumped into the chat as text:
![Company Comparison]()
The "Analyzing..." spinner may also continue indefinitely even after the chat is marked complete
Steps to Reproduce
Logs & Screenshots
Error from Docker logs:
sqlalchemy.exc.StatementError: (builtins.TypeError) Object of type function is not JSON serializable
[SQL: INSERT INTO file (id, user_id, hash, filename, path, data, meta, access_control, created_at, updated_at) VALUES (%(id)s, %(user_id)s, %(hash)s, %(filename)s, %(path)s, %(data)s::JSON, %(meta)s::JSON, %(access_control)s::JSON, %(created_at)s, %(updated_at)s)]
[parameters: [{'meta': {'name': 'generated-image.png', 'content_type': 'image/png', 'size': 24622, 'data': {...}}, ...}]]
2026-01-10 21:29:25.470 | ERROR | open_webui.routers.files:upload_file_handler:336 - 400: [ERROR: Error uploading file]
Stack trace points to:
/app/backend/open_webui/utils/middleware.py, line 3538: get_image_url_from_base64()
/app/backend/open_webui/utils/files.py, line 70: upload_image()
/app/backend/open_webui/routers/images.py, line 512: upload_image()
/app/backend/open_webui/routers/files.py, line 330: upload_file_handler() - HTTPException raised
Root cause: The meta dictionary being passed to upload_file_handler() contains a Python function object that cannot be serialized to JSON when inserting into PostgreSQL.
Screenshot:
Additional Information
Regression: This appears to be a regression introduced in v0.7.x. Code interpreter image rendering worked in v0.6.x.
Database: PostgreSQL (default Docker setup)
Workaround: Using Mermaid diagrams instead of matplotlib bypasses the issue since Mermaid renders client-side without file uploads.
Secondary symptom: The frontend "Analyzing..." spinner may continue spinning indefinitely after the error occurs, even though the backend returns HTTP 200 on /api/chat/completed.
The issue is in how the meta parameter is constructed before being passed to upload_file_handler(). A function reference is being included in the dict. The fix would be in one of:
/app/backend/open_webui/utils/middleware.py around line 3538
/app/backend/open_webui/utils/files.py around line 70
/app/backend/open_webui/routers/images.py around line 512
The meta dict should be sanitized to ensure all values are JSON-serializable before the database INSERT.
@pr-validator-bot commented on GitHub (Jan 10, 2026):
⚠️ Invalid Issue Title
Hey @4republic, please provide a descriptive title for your issue. Titles that are empty, very short (under 10 characters), or generic (like "issue:") make it difficult for volunteer contributors to understand and triage issues.
Please update the title to reflect the content of your issue.
@Classic298 commented on GitHub (Jan 11, 2026):
have a possible fix lined up
@Classic298 commented on GitHub (Jan 11, 2026):
I fully tested this on my end @4republic
https://github.com/open-webui/open-webui/pull/20590
But i dont have PSQL, only sqlite. Please also test the PR on your end to verify this fixed your issue
@rozatoo commented on GitHub (Jan 12, 2026):
Works on my v0.07.2 instance with PSQL!
Applied fix with:
curl -sL https://github.com/open-webui/open-webui/pull/20590.patch | git apply -+ rebuild@Classic298 commented on GitHub (Jan 12, 2026):
@tjbck
@4republic commented on GitHub (Jan 18, 2026):
I haven't had a chance to apply the patch myself, but given rozatoo's confirmation, I'm satisfied this resolves the issue. Appreciate the turnaround!
@Classic298 commented on GitHub (Jan 18, 2026):
@4republic please do test it. Your setup might differ.
@tjbck commented on GitHub (Mar 8, 2026):
Should be addressed in dev.
@Classic298 commented on GitHub (Mar 8, 2026):
1364df0913