Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the Veo video generation model helper to exclude inline video bytes from the raw payload dump of the GenerateVideosOperation response, as they are already delivered to the caller as a data URL in the media part. It also adds corresponding unit tests to verify that inline video bytes are excluded from the raw output and that they correctly survive a JSON round trip as a data URL. I have no feedback to provide as there are no review comments.
| _NON_UTF8_VIDEO = b'\x00\x00\x00\x18ftypmp42\x00\x00\x00\x00\xff\xfe\x80' | ||
|
|
||
|
|
||
| def _inline_bytes_op() -> genai_types.GenerateVideosOperation: |
There was a problem hiding this comment.
The tests only build one video, so a regression on the second one isn't caught:
'__all__' -> 0 in _veo.py -> suite passes
number_of_videos=2 on Vertex -> 2nd video's bytes back in raw as multi-MB base64
Might be worth having _inline_bytes_op return two non-UTF-8 videos and checking both entries in raw.
| raw_payload = response.model_dump(by_alias=True, exclude_none=True) | ||
| # Inline video bytes already reach the caller as a data URL in the media part. | ||
| raw_payload = response.model_dump( | ||
| mode='json', |
There was a problem hiding this comment.
Is dropping the bytes from raw deliberate? mode='json' alone seems to fix the crash, so the exclude is a separate choice:
mode='json' only -> raw keeps videoBytes as URL-safe base64, no crash
mode='json' + exclude -> raw has no videoBytes (this PR)
Go (googlegenai/veo.go:263) -> raw keeps videoBytes as base64
JS (vertexai/converters.ts:458) -> raw keeps the bytes, REST shape
Smaller raw here, but it no longer matches Go.
cabljac
left a comment
There was a problem hiding this comment.
Holding off on this one for now, let's address any comments, get it up to date and sync with the team on how/when it should go in (so we don't step on toes)
|
@huangjeff5 @hilariie heads up — since Python SDK development has moved to https://github.com/genkit-ai/genkit-python (and @hilariie already ported the MCP PRs over there), could we re-open this Veo fix on genkit-ai/genkit-python so we can close it out here? |
|
Moved to genkit-ai/genkit-python#161 |
Why
Vertex Veo fails in the Dev UI with
Error serializing to JSON: invalid utf-8 sequence. Withoutoutput_gcs_uri, Vertex returns the video inline asvideo_bytes._from_veo_operationdumped the SDK response intorawin Python mode, so the raw bytes stayed asbytesandOperation.model_dump_json()raised. The Gemini API returns a download URI instead, so it was never affected.Changes
rawis now dumped in JSON mode withgenerated_videos[].video.video_bytesexcluded. The video still reaches the caller as a base64 data URL in the media part, which is where callers should read it from;rawno longer carries a second multi-MB copy.rawhas novideoBytes, and the media data URL survives a JSON round trip.Verification
output_gcs_urinow renders in the Dev UI.