Repository navigation
fix: 修复 Omni 视频 MIME 枚举缺失导致的 502 - #93
Merged
Mag1cFall merged 2 commits intoNov 1, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题与修复
在 API 试用页使用
gemini-omni-1.1-flash图生视频时,CreateInteractionStream实际可能返回视频 delta[null,"<BASE64 MP4>"]。v0.2.18 的解码器要求 MIME 字段为整数,导致已返回的视频在$delta[1][4][0]被拒绝,请求最终以 502「期望整数」失败。本次修改只对视频 delta 的空 MIME 枚举增加兼容:Base64 解码后通过
http.DetectContentType确认为video/mp4,再输出媒体事件。保留原数值枚举路径;未知非空枚举、无效 Base64、无法识别为 MP4 的数据仍返回协议错误,图片处理不变。同时补充协议文档和回归测试。复现证据
POST /v1beta/models/gemini-omni-1.1-flash:streamGenerateContent?alt=sse。responseModalities=["VIDEO"]、responseFormat.video={"aspectRatio":"16:9","duration":"4s","resolution":"360p"}、videoConfig.task="image_to_video"。null,第二字段为 Base64 视频。诊断代码未包含在本 PR 中。验证
TestDecodeInteractionMedia:10 个案例通过,覆盖缺失枚举、原数值视频/图片格式及异常数据。TestDecodeInteractionStreamVideoWithoutMIME:完整事件流成功输出视频与结束事件,视频字节保持不变。go test -p 4 -mod=readonly -tags netgo,osusergo -ldflags="-linkmode external -extldflags '-static'" ./internal/aistudio -run 'TestDecodeInteraction' -v(Go 1.27.3、Zig musl 工具链、官方 SpiderMonkey 静态库)。internal/aistudio测试集尝试在本地 WSL 静态链接环境运行时,于既有runtime_lease_test.go:21的t.Setenv路径发生 SIGSEGV,因此不将全量测试标记为通过。PR 不包含凭据、用户媒体、部署配置或编译产物。