Skip to content

fix: use glob matching for Gemini image MIME types#12511

Merged
comfyanonymous merged 1 commit intoComfy-Org:masterfrom
huntcsg:fix/gemini-image-mime-type-matching
Feb 18, 2026
Merged

fix: use glob matching for Gemini image MIME types#12511
comfyanonymous merged 1 commit intoComfy-Org:masterfrom
huntcsg:fix/gemini-image-mime-type-matching

Conversation

@huntcsg
Copy link
Copy Markdown
Contributor

@huntcsg huntcsg commented Feb 18, 2026

Problem

gemini-3-pro-image-preview nondeterministically returns image/jpeg instead of image/png in response inlineData. get_image_from_response() hardcodes get_parts_by_type(response, "image/png"), which silently drops JPEG responses and falls back to torch.zeros((1, 1024, 1024, 4)) — producing all-black (0,0,0,0 RGBA) output images.

Confirmed via API response logs: successful runs had mimeType: "image/png", failed (black) runs had mimeType: "image/jpeg". 100% correlation.

Fix

  • Add _mime_matches() helper using fnmatch for glob-style MIME matching (e.g. "image/*" matches "image/png", "image/jpeg", "image/webp")
  • Change get_parts_by_type() to use _mime_matches() instead of == for MIME comparison
  • Change get_image_from_response() to request "image/*" instead of "image/png"

Uses mime.value (not str(mime)) to ensure correct behavior on Python 3.10 where str() on a str Enum returns "ClassName.member" instead of the value.

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

gemini-3-pro-image-preview nondeterministically returns image/jpeg
instead of image/png. get_image_from_response() hardcoded
get_parts_by_type(response, "image/png"), silently dropping JPEG
responses and falling back to torch.zeros (all-black output).

Add _mime_matches() helper using fnmatch for glob-style MIME matching.
Change get_image_from_response() to request "image/*" so any image
format returned by the API is correctly captured.
@huntcsg huntcsg force-pushed the fix/gemini-image-mime-type-matching branch from a11171c to 370810c Compare February 18, 2026 04:58
@comfyanonymous comfyanonymous merged commit 83dd65f into Comfy-Org:master Feb 18, 2026
15 checks passed
@huntcsg huntcsg deleted the fix/gemini-image-mime-type-matching branch February 18, 2026 05:05
comfyanonymous pushed a commit that referenced this pull request Feb 18, 2026
gemini-3-pro-image-preview nondeterministically returns image/jpeg
instead of image/png. get_image_from_response() hardcoded
get_parts_by_type(response, "image/png"), silently dropping JPEG
responses and falling back to torch.zeros (all-black output).

Add _mime_matches() helper using fnmatch for glob-style MIME matching.
Change get_image_from_response() to request "image/*" so any image
format returned by the API is correctly captured.
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.

3 participants