Skip to content

fix(api-nodes-nanobana): raise error when not output image is present#13167

Merged
Kosinkadink merged 4 commits intomasterfrom
fix/gemini-black-image-error-handling
Mar 27, 2026
Merged

fix(api-nodes-nanobana): raise error when not output image is present#13167
Kosinkadink merged 4 commits intomasterfrom
fix/gemini-black-image-error-handling

Conversation

@bigcat88
Copy link
Copy Markdown
Contributor

@bigcat88 bigcat88 commented Mar 26, 2026

When Gemini refuses a prompt (e.g. content policy) or responds with text only, the image nodes returned a silent black 1024x1024 tensor.
Now raises a ValueError with the model's text response so users understand why generation failed.

  • Affects GeminiImage, GeminiImage2, and GeminiNanoBanana2 nodes
  • Preserves black placeholder for optional thought_image output in NanoBanana2

Note: Text-only prompts (e.g. what is 2+2?) now raise an error instead of returning a black image.
This is intentional (we can't distinguish clear text replies from replies with error) - for text generation, use the Google Gemini LLM node instead.

API Node PR Checklist

Scope

  • Is API Node Change

Pricing & Billing

  • Need pricing update
  • No pricing update

If Need pricing update:

  • Metronome rate cards updated
  • Auto‑billing tests updated and passing

QA

  • QA done
  • QA not required

Comms

  • Informed Kosinkadink

Signed-off-by: bigcat88 <bigcat88@icloud.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

The get_image_from_response function in comfy_api_nodes/nodes_gemini.py now implements improved error handling when no image tensors are collected and thought is False. Instead of returning a zero-filled tensor, the function attempts to extract the model's text output and raises a ValueError with the response included. If no text is present, it raises a generic ValueError suggesting a retry with a different response modality setting.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: raising an error when no output image is present, which aligns with the changeset's core modification to error handling in Gemini image nodes.
Description check ✅ Passed The PR description clearly explains the changes: raising ValueError with model response when no image is generated, affecting specific Gemini nodes, with intentional behavior changes documented.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Kosinkadink Kosinkadink merged commit 6a2cdb8 into master Mar 27, 2026
22 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