LAION-AI / LAION-AI/Open-Assistant

[BUG] user_id is actually username

Open
#2,750 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
37.4k
Forks
3.3k
PR merge metrics
No merged PRs in 30d

Description

SQLAl;chemy returns an error

SQLAlchemy error

open-assistant-inference-db-1         | 2023-04-19 11:31:22.491 UTC [48] ERROR:  insert or update on table "chat" violates foreign key constraint "chat_user_id_fkey"
open-assistant-inference-db-1         | 2023-04-19 11:31:22.491 UTC [48] DETAIL:  Key (user_id)=(devddd) is not present in table "user".
open-assistant-inference-db-1         | 2023-04-19 11:31:22.491 UTC [48] STATEMENT:  INSERT INTO chat (hidden, id, user_id, created_at, modified_at, title) VALUES ($1::bool, $2::varchar, $3::varchar, $4::timestamp, $5::timestamp, $6::varchar)
open-assistant-inference-server-1     | 2023-04-19 11:31:22.492 | ERROR    | main:log_exceptions:36 - Exception in request
open-assistant-inference-server-1     | Traceback (most recent call last):
open-assistant-inference-server-1     |
open-assistant-inference-server-1     |   File "/var/opt/inference/server/lib/sqlalchemy/dialects/postgresql/asyncpg.py", line 442, in _prepare_and_execute
open-assistant-inference-server-1     |     self._rows = await prepared_stmt.fetch(*parameters)
open-assistant-inference-server-1     |     │    │             │             │      └ (False, '0643fd10-a7d4-7ff1-8000-5600ec2bf3d8', 'devddd', datetime.datetime(2023, 4, 19, 11, 31, 22, 489515), datetime.dateti...
open-assistant-inference-server-1     |     │    │             │             └ <function PreparedStatement.fetch at 0x7f1ff4fd00d0>
open-assistant-inference-server-1     |     │    │             └ <asyncpg.prepared_stmt.PreparedStatement object at 0x7f1ff0ace2a0>
open-assistant-inference-server-1     |     │    └ <member '_rows' of 'AsyncAdapt_asyncpg_cursor' objects>
open-assistant-inference-server-1     |     └ <sqlalchemy.dialects.postgresql.asyncpg.AsyncAdapt_asyncpg_cursor object at 0x7f1ff1384200>
open-assistant-inference-server-1     |
open-assistant-inference-server-1     |   File "/var/opt/inference/server/lib/asyncpg/prepared_stmt.py", line 176, in fetch
open-assistant-inference-server-1     |     data = await self.__bind_execute(args, 0, timeout)
open-assistant-inference-server-1     |                  │                   │        └ None
open-assistant-inference-server-1     |                  │                   └ (False, '0643fd10-a7d4-7ff1-8000-5600ec2bf3d8', 'devddd', datetime.datetime(2023, 4, 19, 11, 31, 22, 489515), datetime.dateti...
open-assistant-inference-server-1     |                  └ <asyncpg.prepared_stmt.PreparedStatement object at 0x7f1ff0ace2a0>
open-assistant-inference-server-1     |
open-assistant-inference-server-1     |   File "/var/opt/inference/server/lib/asyncpg/prepared_stmt.py", line 241, in __bind_execute
open-assistant-inference-server-1     |     data, status, _ = await self.__do_execute(
open-assistant-inference-server-1     |                             └ <asyncpg.prepared_stmt.PreparedStatement object at 0x7f1ff0ace2a0>
open-assistant-inference-server-1     |
open-assistant-inference-server-1     |   File "/var/opt/inference/server/lib/asyncpg/prepared_stmt.py", line 230, in __do_execute
open-assistant-inference-server-1     |     return await executor(protocol)
open-assistant-inference-server-1     |                  │        └ <asyncpg.protocol.protocol.Protocol object at 0x7f1ff40166c0>
open-assistant-inference-server-1     |                  └ <function PreparedStatement.__bind_execute.<locals>.<lambda> at 0x7f1ff0ad97e0>
open-assistant-inference-server-1     |
open-assistant-inference-server-1     |   File "asyncpg/protocol/protocol.pyx", line 201, in bind_execute
open-assistant-inference-server-1     |     return await waiter
open-assistant-inference-server-1     |
open-assistant-inference-server-1     | asyncpg.exceptions.ForeignKeyViolationError: insert or update on table "chat" violates foreign key constraint "chat_user_id_fkey"
open-assistant-inference-server-1     | DETAIL:  Key (user_id)=(devddd) is not present in table "user".

because here user_id is actually username (devddd for example, instead of 8382e429-ad3e-41ea-9712-648ee569faa2)

https://github.com/LAION-AI/Open-Assistant/blob/4b79215b2f5f4e6e1eca9f375fbf3cfef1f7575b/inference/server/oasst_inference_server/user_chat_repository.py#L57

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at inference/server/oasst_inference_server/user_chat_repository.py around line 57 and trace how the chat user value is obtained before the INSERT. Reproduce the foreign-key failure using the reported username and user ID values, then verify that chat creation uses the user reference expected by the user table and no longer raises the reported PostgreSQL error.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python, sqlalchemy
Domain
backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.