Skip to content

Commit cac5dd1

Browse files
authored
fix: handle null data in model_response_handler (open-webui#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.
1 parent f751c0b commit cac5dd1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

backend/open_webui/routers/channels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ async def model_response_handler(request, channel, message, user, db=None):
10651065
f"{username}: {replace_mentions(thread_message.content)}"
10661066
)
10671067

1068-
thread_message_files = thread_message.data.get("files", [])
1068+
thread_message_files = (thread_message.data or {}).get("files", [])
10691069
for file in thread_message_files:
10701070
if file.get("type", "") == "image":
10711071
images.append(file.get("url", ""))

0 commit comments

Comments
 (0)