mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 23:21:44 -05:00
[PR #21886] [CLOSED] fix: handle non-numeric timestamp values in chat_message migration #81196
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/21886
Author: @npuigm
Created: 2/26/2026
Status: ❌ Closed
Base:
dev← Head:fix/migration-timestamp-type-coercion📝 Commits (1)
96636f1fix: handle non-numeric timestamp values in chat_message migration📊 Changes
1 file changed (+7 additions, -0 deletions)
View changed files
📝
backend/open_webui/migrations/versions/8452d01d26d7_add_chat_message_table.py(+7 -0)📄 Description
Summary
The alembic migration
8452d01d26d7_add_chat_message_table(introduced in v0.8.5) crashes when thetimestampfield inside chat message JSON data contains a non-numeric string value.Root cause: The migration reads
message.get("timestamp", now)and immediately compares it with>and<against integers (lines 131–135). Iftimestampis a string, Python raises:This rolls back the entire migration transaction. On the next startup, the app finds an incomplete schema and returns 500 on
/api/config, showing users "Open WebUI Backend Required".How string timestamps get into the database: In our case, an automated security scanner (DAST) injected path-traversal payloads (
/etc/passwd,c:/Windows/system.ini, etc.) into the chat API, which were stored verbatim in thetimestampfield of 99 chat messages. Any corrupted or manually edited chat data with non-numeric timestamps would trigger the same crash.Fix
timestampinint()with atry/except (TypeError, ValueError)before the numeric comparisonsnow— consistent with the existing fallback for out-of-range timestampsTest plan
int(1234567890)→ same value)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.