[PR #21393] [CLOSED] fix: handle already-deserialized JSON values from PostgreSQL #26064

Closed
opened 2026-04-20 06:17:52 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21393
Author: @lewisco
Created: 2/13/2026
Status: Closed

Base: mainHead: fix/jsonfield-double-deserialization


📝 Commits (1)

  • f2d93a8 fix: handle already-deserialized JSON values from PostgreSQL

📊 Changes

1 file changed (+5 additions, -2 deletions)

View changed files

📝 backend/open_webui/internal/db.py (+5 -2)

📄 Description

Summary

  • JSONField.process_result_value unconditionally calls json.loads() on column values, but PostgreSQL's psycopg2 driver with native JSON handling returns Python dicts/lists directly from JSONB columns
  • This causes TypeError: the JSON object must be str, bytes or bytearray, not dict on PostgreSQL deployments
  • Fix adds a type check to skip deserialization when the value is already a dict or list

Test plan

  • Verify on PostgreSQL deployment that JSONB columns load without TypeError
  • Verify on SQLite deployment that string-serialized JSON values still deserialize correctly
  • Confirm no regression in chat history, user settings, or other JSONField-backed models

🤖 Generated with Claude Code


🔄 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/21393 **Author:** [@lewisco](https://github.com/lewisco) **Created:** 2/13/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/jsonfield-double-deserialization` --- ### 📝 Commits (1) - [`f2d93a8`](https://github.com/open-webui/open-webui/commit/f2d93a802590b22df2aa46f3db0d0aed79e8538b) fix: handle already-deserialized JSON values from PostgreSQL ### 📊 Changes **1 file changed** (+5 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/internal/db.py` (+5 -2) </details> ### 📄 Description ## Summary - `JSONField.process_result_value` unconditionally calls `json.loads()` on column values, but PostgreSQL's `psycopg2` driver with native JSON handling returns Python dicts/lists directly from JSONB columns - This causes `TypeError: the JSON object must be str, bytes or bytearray, not dict` on PostgreSQL deployments - Fix adds a type check to skip deserialization when the value is already a `dict` or `list` ## Test plan - [ ] Verify on PostgreSQL deployment that JSONB columns load without TypeError - [ ] Verify on SQLite deployment that string-serialized JSON values still deserialize correctly - [ ] Confirm no regression in chat history, user settings, or other JSONField-backed models 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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-04-20 06:17:52 -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#26064