[GH-ISSUE #12701] issue: Search in postgres is not working. #55356

Closed
opened 2026-05-05 17:28:43 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @crelocks on GitHub (Apr 10, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/12701

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of Open WebUI.

Installation Method

Git Clone

Open WebUI Version

6.3.1

Ollama Version (if applicable)

No response

Operating System

Mac

Browser (if applicable)

Chrome

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have listed steps to reproduce the bug in detail.

Expected Behavior

Search should work as expected like in sqlite

Actual Behavior

When I search chats in the sidebar, I see an error in the backend.

Steps to Reproduce

Search in the sidebar

Logs & Screenshots

This is the error logs from the backend

  File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/orm/query.py", line 2853, in _iter
    result: Union[ScalarResult[_T], Result[_T]] = self.session.execute(
                                                  ^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 2365, in execute
    return self._execute_internal(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 2251, in _execute_internal
    result: Result[Any] = compile_state_cls.orm_execute_statement(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/orm/context.py", line 305, in orm_execute_statement
    result = conn.execute(
             ^^^^^^^^^^^^^
  File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1416, in execute
    return meth(
           ^^^^^
  File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/sql/elements.py", line 516, in _execute_on_connection
    return connection._execute_clauseelement(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1638, in _execute_clauseelement
    ret = self._execute_context(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1843, in _execute_context
    return self._exec_single_context(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1983, in _exec_single_context
    self._handle_dbapi_exception(
  File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2352, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1964, in _exec_single_context
    self.dialect.do_execute(
  File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 942, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.DataError: (psycopg2.errors.InvalidParameterValue) cannot call json_array_elements on a non-array

[SQL: SELECT chat.id AS chat_id, chat.user_id AS chat_user_id, chat.title AS chat_title, chat.chat AS chat_chat, chat.created_at AS chat_created_at, chat.updated_at AS chat_updated_at, chat.share_id AS chat_share_id, chat.archived AS chat_archived, chat.pinned AS chat_pinned, chat.meta AS chat_meta, chat.folder_id AS chat_folder_id
FROM chat
WHERE chat.user_id = %(user_id_1)s AND chat.archived = false AND (chat.title ILIKE %(title_1)s OR
                            EXISTS (
                                SELECT 1
                                FROM json_array_elements(Chat.chat->'messages') AS message
                                WHERE LOWER(message->>'content') LIKE '%%' || %(search_text)s || '%%'
                            )
                            ) ORDER BY chat.updated_at DESC
 LIMIT %(param_1)s OFFSET %(param_2)s]
[parameters: {'user_id_1': '3be78c56-b86d-49ed-8b63-fba581565cfe', 'title_1': '%project%', 'search_text': 'project', 'param_1': 60, 'param_2': 0}]
(Background on this error at: https://sqlalche.me/e/20/9h9h)

Additional Information

No response

Originally created by @crelocks on GitHub (Apr 10, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/12701 ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Git Clone ### Open WebUI Version 6.3.1 ### Ollama Version (if applicable) _No response_ ### Operating System Mac ### Browser (if applicable) Chrome ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have listed steps to reproduce the bug in detail. ### Expected Behavior Search should work as expected like in sqlite ### Actual Behavior When I search chats in the sidebar, I see an error in the backend. ### Steps to Reproduce Search in the sidebar ### Logs & Screenshots This is the error logs from the backend ``` File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/orm/query.py", line 2853, in _iter result: Union[ScalarResult[_T], Result[_T]] = self.session.execute( ^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 2365, in execute return self._execute_internal( ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 2251, in _execute_internal result: Result[Any] = compile_state_cls.orm_execute_statement( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/orm/context.py", line 305, in orm_execute_statement result = conn.execute( ^^^^^^^^^^^^^ File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1416, in execute return meth( ^^^^^ File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/sql/elements.py", line 516, in _execute_on_connection return connection._execute_clauseelement( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1638, in _execute_clauseelement ret = self._execute_context( ^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1843, in _execute_context return self._exec_single_context( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1983, in _exec_single_context self._handle_dbapi_exception( File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2352, in _handle_dbapi_exception raise sqlalchemy_exception.with_traceback(exc_info[2]) from e File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1964, in _exec_single_context self.dialect.do_execute( File "/home/ubuntu/chat-webui/backend/venv/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 942, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.DataError: (psycopg2.errors.InvalidParameterValue) cannot call json_array_elements on a non-array [SQL: SELECT chat.id AS chat_id, chat.user_id AS chat_user_id, chat.title AS chat_title, chat.chat AS chat_chat, chat.created_at AS chat_created_at, chat.updated_at AS chat_updated_at, chat.share_id AS chat_share_id, chat.archived AS chat_archived, chat.pinned AS chat_pinned, chat.meta AS chat_meta, chat.folder_id AS chat_folder_id FROM chat WHERE chat.user_id = %(user_id_1)s AND chat.archived = false AND (chat.title ILIKE %(title_1)s OR EXISTS ( SELECT 1 FROM json_array_elements(Chat.chat->'messages') AS message WHERE LOWER(message->>'content') LIKE '%%' || %(search_text)s || '%%' ) ) ORDER BY chat.updated_at DESC LIMIT %(param_1)s OFFSET %(param_2)s] [parameters: {'user_id_1': '3be78c56-b86d-49ed-8b63-fba581565cfe', 'title_1': '%project%', 'search_text': 'project', 'param_1': 60, 'param_2': 0}] (Background on this error at: https://sqlalche.me/e/20/9h9h) ``` ### Additional Information _No response_
GiteaMirror added the bug label 2026-05-05 17:28:43 -05:00
Author
Owner

@crelocks commented on GitHub (Apr 10, 2025):

Sorry, I jumped the gun.. not an issue

<!-- gh-comment-id:2792964004 --> @crelocks commented on GitHub (Apr 10, 2025): Sorry, I jumped the gun.. not an issue
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#55356