Skip to content

fix(gemini): fix Express aspect ratio and image-block error surfacing - #73

Merged
MegalithOfficial merged 1 commit into
LettuceAI:mainfrom
rppavan:main
Jul 12, 2026
Merged

fix(gemini): fix Express aspect ratio and image-block error surfacing#73
MegalithOfficial merged 1 commit into
LettuceAI:mainfrom
rppavan:main

Conversation

@rppavan

@rppavan rppavan commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Express/Vertex image generation rejected the responseFormat.image.aspectRatio
field added in 4bfb98e (400 INVALID_ARGUMENT); it expects imageConfig.aspectRatio
instead. Split the shared payload builder so each Gemini surface gets the field
shape it actually supports.

Also, Gemini omits parts entirely when it hard-blocks image generation (e.g.
finishReason=IMAGE_PROHIBITED_CONTENT), which made parsing fail with a generic
"missing field parts" instead of surfacing the finishMessage.

Tested: cargo test --lib image_generator::provider_adapter::google_gemini (4/4
pass), cargo build --lib clean.

By apparao.parwatikar

Express/Vertex image generation rejected the responseFormat.image.aspectRatio
field added in 4bfb98e (400 INVALID_ARGUMENT); it expects imageConfig.aspectRatio
instead. Split the shared payload builder so each Gemini surface gets the field
shape it actually supports.

Also, Gemini omits `parts` entirely when it hard-blocks image generation (e.g.
finishReason=IMAGE_PROHIBITED_CONTENT), which made parsing fail with a generic
"missing field `parts`" instead of surfacing the finishMessage.

Tested: cargo test --lib image_generator::provider_adapter::google_gemini (4/4
pass), cargo build --lib clean.

By apparao.parwatikar

@MegalithOfficial MegalithOfficial left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. The payload split correctly handles the different aspect-ratio fields required by the Gemini Developer API and Vertex/Express, and the blocked-response handling now surfaces the useful finishMessage instead of a parsing error. The added tests cover both fixes well. Approved!

@MegalithOfficial
MegalithOfficial merged commit 4f27894 into LettuceAI:main Jul 12, 2026
4 checks passed
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.

2 participants