[Bug] 部分中转返回裸 URL 图像内容时解析失败:Unable to extract image(Raw message type: str)
Author: zgybkjcn-a11yCreated Sep 12, 2026Updated Sep 12, 2026
Deployment Method / 部署方式
Docker Compose (docker-compose.yml)
Issue Description / 问题描述
backend/services/ai_providers/image/openai_provider.py 的 chat-completions 响应解析只覆盖三类图像内容:markdown 图片、base64 裸串、带 URL 前缀标记的文本。
某些 OpenAI 兼容中转(实测为 Adobe Firefly 后端的代理)把生成结果包成一个裸的预签名 URL,且路径没有任何文件扩展名,例如:
https://firefly-upload-storage.s3.amazonaws.com/.../image?X-Amz-Signature=...它不匹配任何现有解析分支,一路落到 logger.warning("Unable to extract image...") —— 中转站明明生成成功了,后端却报「无法提取图像」,这次生成直接失败。
Steps to Reproduce / 复现步骤
- 图像模型接一个返回裸 URL 的中转站(chat 协议路径)
- 触发图像生成
- 后端日志出现
Unable to extract image. Raw message type: <class 'str'>,raw content 是一整条无扩展名的 https URL
Expected Behavior / 期望行为
内容为单条 http(s) URL 时,尝试下载并交给 Image.open 验证确实是图像;是图像就正常返回,不是则维持现有 warning 路径。
建议修复
在 base64 分支之后追加兜底:
bare_url = content_str.strip()
if bare_url.startswith(('http://', 'https://')) and not any(c.isspace() for c in bare_url):
try:
response = requests.get(bare_url, timeout=60, stream=True)
response.raise_for_status()
image = Image.open(BytesIO(response.content))
image.load()
return image
except Exception as download_error:
logger.warning(f"Failed to download image from bare URL: {download_error}")已开 PR,见下方链接。
Version / 版本
main (199cf9e);v0.9.0-rc.7 同样存在
Source: Anionex/banana-slides