Skip to content

[BUG] Deleting a conversation in postgres-based conversation cache throws an error #641

@karthikjeeyar

Description

@karthikjeeyar

Bug Description

When using postgres to persist conversations, deleting a conversation successfully removes that conversation in the database however it throws an error post deletion instead of success response.


2025-06-27 18:47:34,353 [ols.app.endpoints.conversations:conversations.py:153] INFO: Deleting chat history for user: user:development/guest with conversation_id: 168f4f83-578a-45fb-910c-3898af477530
2025-06-27 18:47:34,354 [ols.src.cache.postgres_cache:postgres_cache.py:136] INFO: Connection to storage is ok
2025-06-27 18:47:34,356 [ols.src.cache.postgres_cache:postgres_cache.py:250] ERROR: PostgresCache.delete: no results to fetch
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/app-root/ols/src/cache/postgres_cache.py", line 248, in delete
return PostgresCache._delete(cursor, user_id, conversation_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app-root/ols/src/cache/postgres_cache.py", line 376, in _delete
return cursor.fetchone() is not None
^^^^^^^^^^^^^^^^^
psycopg2.ProgrammingError: no results to fetch
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
await super().__call__(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in __call__
raise exc

To Reproduce

Steps to reproduce the behavior:

  1. Use postgres type for conversation_cache.
  conversation_cache:
    type: postgres
    postgres:
        host: localhost
        port: 5432
        dbname: postgres
        user: postgres
        password_path: postgres_password.txt
  1. Create a conversation
  2. Delete the newly created conversation using DELETE /conversations/<conversation_id> endpoint
  3. See error in the server logs.

Expected behavior

After deleting the conversation, the endpoint should not throw any error instead it should return successful response.

Screenshots or output

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions