-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Describe the bug
When using the SQLAlchemy data layer with SQLite, in get_all_user_threads()
, the returned metadata
seems to be a JSON string but it is not ever deserialized.
chainlit/backend/chainlit/data/sql_alchemy.py
Line 623 in 8e739b3
metadata=thread["thread_metadata"], |
For me, backend/chainlit/socket.py
, line 53 in resume_thread()
subsequently fails attempting metadata.copy()
triggered by having an implementation of @on_chat_resume
.
Interestingly, similar case seems to be correctly handled elsewhere in the same module:
chainlit/backend/chainlit/data/sql_alchemy.py
Lines 126 to 129 in 8e739b3
# SQLite returns JSON as string, we most convert it. (#1137) | |
metadata = user_data.get("metadata", {}) | |
if isinstance(metadata, str): | |
metadata = json.loads(metadata) |
Given that, I'd go as far as to suggest the whole module should be reviewed; there might be other places where deserialization is missing.
To Reproduce
Try out anything that uses the metadata using SQLAlchemy + SQLite. I tried on_chat_resume which appears to trigger the problematic code.
For what it's worth, I thought SQLAlchemy handled this kind of differences transparently, unless it is being used in a low-level way... ?