fix: handle undefined file.url in UserMessage to prevent TypeError (#20343)

Add optional chaining to file.url.startsWith() calls to safely handle cases where file.url is undefined, preventing 'can't access property startsWith' TypeError in user messages with file attachments.
This commit is contained in:
G30
2026-01-03 09:10:03 -05:00
committed by GitHub
parent ccd3295a5d
commit cfecca8eda

View File

@@ -194,7 +194,7 @@
>
{#each message.files as file}
{@const fileUrl =
file.url.startsWith('data') || file.url.startsWith('http')
file.url?.startsWith('data') || file.url?.startsWith('http')
? file.url
: `${WEBUI_API_BASE_URL}/files/${file.url}${file?.content_type ? '/content' : ''}`}
<div class={($settings?.chatBubble ?? true) ? 'self-end' : ''}>