828155e fix(chats): handle null bytes in PostgreSQL search
62a5a2a fix(chats): prevent null byte errors in PostgreSQL queries
📊 Changes
1 file changed (+7 additions, -2 deletions)
View changed files
📝backend/open_webui/models/chats.py (+7 -2)
📄 Description
Changelog Entry
Description
This PR fixes a PostgreSQL-specific issue where chat searches would crash when encountering null bytes (\u0000 or \x00) in chat messages or titles. PostgreSQL does not allow null bytes in text fields, causing database errors during search operations. The fix adds proper filtering to exclude chats containing null bytes before attempting text extraction and comparison operations.
Added
Added null byte filtering for PostgreSQL chat message content using JSON representation check
Added null byte filtering for PostgreSQL chat titles
Changed
Updated PostgreSQL chat search query to check for null bytes in message content before text extraction
Modified search logic to explicitly check message->'content' IS NOT NULL before processing
Deprecated
N/A
Removed
N/A
Fixed
Fixed PostgreSQL crashes when searching chats containing null bytes in message content
Fixed PostgreSQL errors when searching chats with null bytes in titles
Security
N/A
Breaking Changes
N/A
Additional Information
The fix specifically targets PostgreSQL databases where null bytes in JSON text fields cause errors. The solution:
Checks if message content is not null before processing
Filters out messages containing \u0000 in their JSON representation
Filters out chat titles containing \x00 (null bytes)
This ensures the search operation only processes valid text content without null bytes, preventing database errors while maintaining search functionality.
Screenshots or Videos
N/A (Backend database query fix)
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.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/18576
**Author:** [@Davixk](https://github.com/Davixk)
**Created:** 10/24/2025
**Status:** ✅ Merged
**Merged:** 11/6/2025
**Merged by:** [@tjbck](https://github.com/tjbck)
**Base:** `dev` ← **Head:** `fix/postgres-chats-search`
---
### 📝 Commits (2)
- [`828155e`](https://github.com/open-webui/open-webui/commit/828155e7f9650c689f0e99f3d3398ffe1e6d7d4d) fix(chats): handle null bytes in PostgreSQL search
- [`62a5a2a`](https://github.com/open-webui/open-webui/commit/62a5a2a81b66a9c36b51957ddb16c7fc82d72fe2) fix(chats): prevent null byte errors in PostgreSQL queries
### 📊 Changes
**1 file changed** (+7 additions, -2 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/models/chats.py` (+7 -2)
</details>
### 📄 Description
# Changelog Entry
### Description
This PR fixes a PostgreSQL-specific issue where chat searches would crash when encountering null bytes (`\u0000` or `\x00`) in chat messages or titles. PostgreSQL does not allow null bytes in text fields, causing database errors during search operations. The fix adds proper filtering to exclude chats containing null bytes before attempting text extraction and comparison operations.
### Added
- Added null byte filtering for PostgreSQL chat message content using JSON representation check
- Added null byte filtering for PostgreSQL chat titles
### Changed
- Updated PostgreSQL chat search query to check for null bytes in message content before text extraction
- Modified search logic to explicitly check `message->'content' IS NOT NULL` before processing
### Deprecated
- N/A
### Removed
- N/A
### Fixed
- Fixed PostgreSQL crashes when searching chats containing null bytes in message content
- Fixed PostgreSQL errors when searching chats with null bytes in titles
### Security
- N/A
### Breaking Changes
- N/A
---
### Additional Information
The fix specifically targets PostgreSQL databases where null bytes in JSON text fields cause errors. The solution:
1. Checks if message content is not null before processing
2. Filters out messages containing `\u0000` in their JSON representation
3. Filters out chat titles containing `\x00` (null bytes)
This ensures the search operation only processes valid text content without null bytes, preventing database errors while maintaining search functionality.
### Screenshots or Videos
- N/A (Backend database query fix)
### Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/18576
Author: @Davixk
Created: 10/24/2025
Status: ✅ Merged
Merged: 11/6/2025
Merged by: @tjbck
Base:
dev← Head:fix/postgres-chats-search📝 Commits (2)
828155efix(chats): handle null bytes in PostgreSQL search62a5a2afix(chats): prevent null byte errors in PostgreSQL queries📊 Changes
1 file changed (+7 additions, -2 deletions)
View changed files
📝
backend/open_webui/models/chats.py(+7 -2)📄 Description
Changelog Entry
Description
This PR fixes a PostgreSQL-specific issue where chat searches would crash when encountering null bytes (
\u0000or\x00) in chat messages or titles. PostgreSQL does not allow null bytes in text fields, causing database errors during search operations. The fix adds proper filtering to exclude chats containing null bytes before attempting text extraction and comparison operations.Added
Changed
message->'content' IS NOT NULLbefore processingDeprecated
Removed
Fixed
Security
Breaking Changes
Additional Information
The fix specifically targets PostgreSQL databases where null bytes in JSON text fields cause errors. The solution:
\u0000in their JSON representation\x00(null bytes)This ensures the search operation only processes valid text content without null bytes, preventing database errors while maintaining search functionality.
Screenshots or Videos
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.