fix: handle null data in model_response_handler (#21112)

Fix `AttributeError` in `model_response_handler` when processing channel messages with `null` data field. The function iterates over thread messages to build conversation history, but some messages may have `data=None` causing a crash when accessing `thread_message.data.get()`. Added null check using `(thread_message.data or {}).get("files", [])` to safely handle messages without data.
This commit is contained in:
G30
2026-02-05 15:15:34 -05:00
committed by GitHub
parent f751c0b46c
commit cac5dd12e9

View File

@@ -1065,7 +1065,7 @@ async def model_response_handler(request, channel, message, user, db=None):
f"{username}: {replace_mentions(thread_message.content)}"
)
thread_message_files = thread_message.data.get("files", [])
thread_message_files = (thread_message.data or {}).get("files", [])
for file in thread_message_files:
if file.get("type", "") == "image":
images.append(file.get("url", ""))