mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #17723] [CLOSED] Fix: Sanitize chat and other user content to prevent PostgreSQL errors #24527
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/17723
Author: @Classic298
Created: 9/24/2025
Status: ❌ Closed
Base:
dev← Head:fix-postgres-null-byte-search-error📝 Commits (2)
c104b9dFix: Sanitize chat and other user content to prevent PostgreSQL errors51c5275Merge branch 'dev' into fix-postgres-null-byte-search-error📊 Changes
5 files changed (+77 additions, -59 deletions)
View changed files
📝
backend/open_webui/models/chats.py(+35 -27)📝
backend/open_webui/models/prompts.py(+6 -4)📝
backend/open_webui/routers/files.py(+2 -1)📝
backend/open_webui/routers/retrieval.py(+16 -27)📝
backend/open_webui/utils/misc.py(+18 -0)📄 Description
This commit introduces a comprehensive sanitization mechanism to prevent null bytes (\u0000) and other C0 control characters from being stored in the database. These characters were causing
UntranslatableCharactererrors during search operations in PostgreSQL deployments.The solution consists of a new centralized function,
sanitize_json_content, which recursively traverses data structures and removes problematic characters from strings.This sanitization is now applied at all relevant data entry points, including:
This proactive approach ensures data integrity and prevents future occurrences of the search error, providing a robust and long-term fix for the issue.
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.