Skip to content

视频按文件头识别:标成图片的 mp4 也转成视频 - #32

Merged
ifccod merged 1 commit into
mainfrom
fix/video-in-image-block
Nov 30, 2026
Merged

ifccod merged 1 commit into
mainfrom
fix/video-in-image-block

Conversation

@ifccod

@ifccod ifccod commented Nov 30, 2026

Copy link
Copy Markdown
Owner

有的客户端把所有附件都写成 image_url,视频也标成 image/png、image/jpeg。之前 videoBlock 只把声明为 video/* 的图片块转成视频块,这种视频会落到上游的图片检查,回 400 an image whose data is not an image (first bytes: 0000001c66747970)(11-30 px-5 上一个 AsyncOpenAI 客户端)。

现在 base64 图片块和 data: 链接先看文件头(mp4/mov/webm/avi),是视频就转成 video 块,交给上游的 view_file。真图片不受影响;HEIC/AVIF 这类 ftyp 图片照旧不算视频。

测试:fork/fork.sh test,patch-e2e 18/18(新增标成 image/png 和 data:image/jpeg 的 mp4 两条,改前都是 400);上游 bun test 的失败项与上游快照相同。

合并后版本为 0.1.178(含上游 0.1.176–0.1.178)。

🤖 Generated with Claude Code

Clients that send every attachment as image_url label a video image/png or
image/jpeg. videoBlock only turned image blocks whose media_type said video/*
into video blocks, so such a video reached upstream's image check and got
400 "an image whose data is not an image (first bytes: 0000001c66747970)"
(seen on px-5, 11-30, an AsyncOpenAI client). Base64 image blocks and data:
URLs are now sniffed for an mp4/mov/webm/avi header first.

patch-e2e: a video labelled image/png and one in a data:image/jpeg URL are
staged for view_file; both were 400 before this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ifccod
ifccod merged commit 4a351df into main Nov 30, 2026
1 check passed
@ifccod
ifccod deleted the fix/video-in-image-block branch November 30, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant