From 69b87a0d8a362b1d93e486da4b466d0317116a37 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sat, 25 Apr 2026 22:43:00 +0800 Subject: [PATCH] fix(pipeline): handle File messages with base64 data in preproc (#2149) File messages from platforms like Telegram carry base64 data with an empty url. The unconditional from_file_url(me.url) call passed an empty string downstream, causing httpx to fail with "Request URL is missing an 'http://' or 'https://' protocol" when uploading to Dify. Mirror the existing Voice handling pattern: check base64 first, fall back to url. Applied in both the main message chain and the Quote path. Closes #2079 Co-authored-by: Junyan Qin Co-authored-by: Claude Opus 4.6 (1M context) --- src/langbot/pkg/pipeline/preproc/preproc.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/langbot/pkg/pipeline/preproc/preproc.py b/src/langbot/pkg/pipeline/preproc/preproc.py index 8794786d..0f865044 100644 --- a/src/langbot/pkg/pipeline/preproc/preproc.py +++ b/src/langbot/pkg/pipeline/preproc/preproc.py @@ -160,7 +160,10 @@ class PreProcessor(stage.PipelineStage): elif me.url: content_list.append(provider_message.ContentElement.from_file_url(me.url, 'voice')) elif isinstance(me, platform_message.File): - content_list.append(provider_message.ContentElement.from_file_url(me.url, me.name)) + if me.base64: + content_list.append(provider_message.ContentElement.from_file_base64(me.base64, me.name)) + elif me.url: + content_list.append(provider_message.ContentElement.from_file_url(me.url, me.name)) elif isinstance(me, platform_message.Quote) and quote_msg: for msg in me.origin: if isinstance(msg, platform_message.Plain): @@ -172,7 +175,10 @@ class PreProcessor(stage.PipelineStage): if msg.base64 is not None: content_list.append(provider_message.ContentElement.from_image_base64(msg.base64)) elif isinstance(msg, platform_message.File): - content_list.append(provider_message.ContentElement.from_file_url(msg.url, msg.name)) + if msg.base64: + content_list.append(provider_message.ContentElement.from_file_base64(msg.base64, msg.name)) + elif msg.url: + content_list.append(provider_message.ContentElement.from_file_url(msg.url, msg.name)) elif isinstance(msg, platform_message.Voice): if msg.base64: content_list.append(