Skip to content

Conversation

@bigcat88
Copy link
Contributor

@bigcat88 bigcat88 commented Jan 13, 2026

Improves error handling for Gemini image generation when safety filters block content.

  • Raises a clear exception when all candidates are blocked due to IMAGE_PROHIBITED_CONTENT
  • Allows partial results if some candidates succeed while others are blocked
  • Fixes edge case where empty candidates list was not handled

This will handle the situation where you ask to generate image with prompt "sexy naked girl" and an empty image is returned.
In this case, it's more appropriate to throw an exception so that other parts of workflow that are waiting for an image don't work with a blank image(which is not expected).

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

@bigcat88 bigcat88 added the Core Core team dependency label Jan 13, 2026
@Kosinkadink Kosinkadink merged commit c543ad8 into master Jan 13, 2026
17 checks passed
@silveroxides
Copy link
Contributor

Might be worthwhile to include the regular PROHIBITED_CONTENT which is for text based queries (IMAGE_PROHIBITED_CONTENT only covers image generative requests iirc), overload and unknown as UNKNOWN. I have such handling in my custom node here since the text detector model they use tends to flag things out of context or even completely nonsensical stuff: https://github.com/silveroxides/ComfyUI_Gemini_Expanded_API/blob/35844f7f9f334bc97f2c5bf4b7d9e38d4518ebed/gemini_nodes.py#L642

@bigcat88 bigcat88 deleted the fix/api-nodes/gemini-image-safety branch January 14, 2026 06:49
@bigcat88
Copy link
Contributor Author

@silveroxides, do you have any prompts I can use to check for PROHIBITED_CONTENT?
I tried adding that while working on this PR, but I never got the blocking results.

So, to avoid breaking anything and adding untested code, I decided to only include what I can test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Core Core team dependency

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants