Skip to content

[Partner Nodes] Stop adding an opaque alpha channel to API node images - #15369

Merged
bigcat88 merged 7 commits into
masterfrom
fix/api-nodes-preserve-alpha
Aug 15, 2026
Merged

[Partner Nodes] Stop adding an opaque alpha channel to API node images#15369
bigcat88 merged 7 commits into
masterfrom
fix/api-nodes-preserve-alpha

Conversation

@christian-byrne

@christian-byrne christian-byrne commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

bytesio_to_image_tensor defaulted to mode="RGBA" and ran image.convert(mode) unconditionally, so every image downloaded by an API node came back as 4 channels — including from the many APIs that return no transparency at all. The 4th channel was a constant 1.0 that no vendor sent.

That costs real behavior downstream, because a 4-channel IMAGE is not interchangeable with a 3-channel one:

  • ImageUpscaleWithModel feeds the tensor to a 3-channel spandrel model.
  • ColorTransfer calls kornia.color.rgb_to_lab, which requires exactly 3 channels.
  • ImageQuantize builds a PIL image with mode='RGB' and reinterprets the buffer.
  • ImageInvert is 1.0 - image, which turns the opaque alpha transparent.
  • Re-uploading to a partner breaks: comfy_api_nodes/nodes_bria.py already carries # Bria's replace_background 500s on RGBA, so drop the alpha channel before upload., and four sites in comfy_api_nodes/nodes_bfl.py strip with # make sure image will have alpha channel removed.

Now the mode defaults to whatever the decoded image actually has: RGBA if it carries transparency, RGB if it does not. Callers that pass an explicit mode are unaffected. Nodes that return genuinely transparent images — Recraft removeBackground, OpenAI background="transparent" — keep their alpha, and it now means something instead of always being present.

Two call sites needed to move with it:

  • nodes_gemini.py — the no-image placeholder was torch.zeros((1, 1024, 1024, 4)), now 3, matching what the node returns on the normal path.
  • nodes_recraft.pyRecraftRemoveBackgroundNode reads its MASK out of the last channel, so it asks for mode="RGBA" explicitly rather than relying on the old default.

On Gemini specifically: the image generation docs (https://ai.google.dev/gemini-api/docs/image-generation) never mention alpha or transparency, response_format exposes only mime_type / aspect_ratio / image_size, and the community models that do sell a transparent Nano Banana produce the alpha by rendering twice and matting. So nothing was being discarded there — a channel was being invented.

Not included: comfy_api_nodes/nodes_openai.py has its own Image.open(img_io).convert("RGBA") in validate_and_cast_response with the same issue. It needs slightly different handling because background="auto" can vary per image within one response and the images are torch.stacked, so it wants a batch-level normalization rather than a per-image default. Left for a separate change.

Tests: tests-unit/comfy_api_nodes_test/image_conversions_test.py covers RGB PNG, JPEG, grayscale, RGBA, palette-with-transparency, and explicit mode=. python -m pytest tests-unit/comfy_api_nodes_test/ passes; ruff check . and pylint comfy_api_nodes clean.

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

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 04ac6109-5ee5-480d-a019-da70d4f09127

📥 Commits

Reviewing files that changed from the base of the PR and between 33d9813 and 3c92268.

📒 Files selected for processing (1)
  • comfy_api_nodes/util/__init__.py
📜 Recent review details
⏰ Context from checks skipped due to timeout. (9)
  • GitHub Check: test (macos-latest)
  • GitHub Check: test (ubuntu-latest)
  • GitHub Check: test (windows-latest)
  • GitHub Check: Run Pylint
  • GitHub Check: test (macos-latest)
  • GitHub Check: test (ubuntu-latest)
  • GitHub Check: test (windows-2022)
  • GitHub Check: test
  • GitHub Check: Run Pylint
🧰 Additional context used
📓 Path-based instructions (6)
**/*

📄 CodeRabbit inference engine (AGENTS.md)

**/*: Keep changes small, direct, and limited to the narrowest necessary code path and smallest number of files.
Prefer practical fixes, minimal dependencies, and existing repository patterns; remove obsolete, dead, unreachable, or unused code.
Preserve existing APIs, node names, model-loading behavior, file layout, and workflow compatibility unless replacement is explicitly intended.
Core ComfyUI must not add outbound internet requests, telemetry, tracking, reporting, remote configuration, or background network activity. User-authorized model downloads are limited to the requested artifact and must exclude telemetry and unrelated metadata.

Files:

  • comfy_api_nodes/util/__init__.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Keep state and capability flags on the object that owns the behavior. Prefer explicit parent-owned attributes over probing child objects with getattr; use child checks only when the child owns the delegated behavior.
Preserve shared method signatures, argument order, return shapes, side effects, and error behavior unless every affected caller and interface is intentionally updated.
Do not add unused compatibility parameters, flags, attributes, constructor options, or model-specific options to shared helpers; keep one-off behavior at the integration boundary.
Normalize third-party return conventions at integration boundaries so core code receives the expected type and shape; avoid undocumented caller-side unwrapping.
Do not add torch.no_grad, torch.inference_mode, or inference-mode wrappers. Do not add model freeze/unfreeze toggles; only disable globally enabled inference mode when a training path requires gradients.
Remove inference-only training behavior such as dropout while preserving checkpoint and state-dict compatibility; use nn.Identity when deleting a module would alter keys or ordering.
Keep imports at module scope except established optional-backend probes or imports required to avoid cycles; avoid unnecessary try/except blocks and use specific exceptions with useful fallbacks.
Do not add workarounds for unsupported library versions, especially PyTorch exception-and-float-cast retries, unless a comment names the exact versions still requiring them.
Let unsupported model formats, invalid quantization metadata, and bad states fail with clear errors instead of silently degrading output.
Match local style, keep comments sparse and useful, and remove comments that merely restate obvious code.
Treat dtype, device placement, VRAM use, and offloading as correctness concerns across CPU, CUDA, ROCm, MPS, DirectML, XPU, NPU, and low-VRAM environments.
Prefer existing ComfyUI and Comfy Kitchen operations, quantization helpers, cast/offload helpe...

Files:

  • comfy_api_nodes/util/__init__.py
**/*.{py,json}

📄 CodeRabbit inference engine (AGENTS.md)

Treat legacy combo, io.Combo, and io.DynamicCombo values affecting filesystem access as untrusted; revalidate them at load/save boundaries with folder_paths, containment checks, or fixed allowlists.

Files:

  • comfy_api_nodes/util/__init__.py
**/*.{py,md,txt,json}

📄 CodeRabbit inference engine (AGENTS.md)

Keep warning and info messages short and actionable, remove noisy or misleading logging, and make documentation edits concise, factual, and tied to changed behavior.

Files:

  • comfy_api_nodes/util/__init__.py
**

⚙️ CodeRabbit configuration file

**: IMPORTANT: Only comment on issues directly introduced by this PR's code changes.
Treat AGENTS.md as mandatory repository policy, not optional style guidance.
Flag PR changes that violate AGENTS.md even when the code is otherwise functional.
In particular, enforce architecture boundaries, dtype/device/memory rules,
interface contracts, import style, no unnecessary try/except blocks, no inline
imports, no outbound internet paths in core ComfyUI, and narrow scoped fixes.
Prefer direct findings over suggestions when a rule is violated. Only ignore
AGENTS.md when it clearly conflicts with a newer explicit maintainer instruction
in the PR.
Do NOT flag pre-existing issues in code that was merely moved, re-indented,
de-indented, or reformatted without logic changes. If code appears in the diff
only due to whitespace or structural reformatting (e.g., removing a with: block),
treat it as unchanged. Contributors should not feel obligated to address
pre-existing issues outside the scope of their contribution.

Files:

  • comfy_api_nodes/util/__init__.py
comfy_api_nodes/**

⚙️ CodeRabbit configuration file

comfy_api_nodes/**: Third-party API integration nodes. Focus on:

  • No hardcoded API keys or secrets
  • Proper error handling for API failures (timeouts, rate limits, auth errors)
  • Correct Pydantic model usage
  • Security of user data passed to external APIs

Files:

  • comfy_api_nodes/util/__init__.py
🧠 Learnings (8)
📚 Learning: 2026-02-21T14:01:41.482Z
Learnt from: pythongosssss
Repo: Comfy-Org/ComfyUI PR: 12555
File: comfy_extras/nodes_glsl.py:719-724
Timestamp: 2026-02-21T14:01:41.482Z
Learning: In PyOpenGL, bare Python scalars can be accepted for 1-element array parameters by NumberHandler. This means you can pass an int/float directly to OpenGL texture deletion (e.g., glDeleteTextures(tex)) without wrapping in a list. Verify function-specific expectations and ensure types match what the OpenGL call expects; use explicit lists only when the API requires an array.

Applied to files:

  • comfy_api_nodes/util/__init__.py
📚 Learning: 2026-04-18T16:55:46.724Z
Learnt from: bigcat88
Repo: Comfy-Org/ComfyUI PR: 13465
File: comfy_api_nodes/nodes_bytedance.py:1496-1506
Timestamp: 2026-04-18T16:55:46.724Z
Learning: In `comfy_api_nodes` Python async node implementations (e.g., `async def execute`), synchronous CPU/IO-heavy helpers (such as video/audio trim/resize and base64/MP3 conversion) may be called directly without offloading to a thread executor (e.g., `asyncio.to_thread`). Treat this as an existing, broader refactor concern rather than a new PR regression: if the PR does not introduce additional synchronous blocking calls, reviewers should not flag it as a new issue. However, if the PR adds new synchronous CPU/IO work inside `async def execute`, prefer offloading with `asyncio.to_thread` (or an equivalent background executor) to avoid blocking the event loop.

Applied to files:

  • comfy_api_nodes/util/__init__.py
📚 Learning: 2026-05-07T17:59:26.050Z
Learnt from: bigcat88
Repo: Comfy-Org/ComfyUI PR: 13753
File: comfy_api_nodes/nodes_gemini.py:1148-1157
Timestamp: 2026-05-07T17:59:26.050Z
Learning: In ComfyUI node implementations under `comfy_api_nodes/`, when building JSONata expressions that use `IO.PriceBadge` for `$lookup` against a price map keyed in lowercase, do not add an explicit `$lowercase()` around widget values (e.g., combo options like "1K", "2K", "4K"). The ComfyUI frontend automatically lowercases widget values before evaluating the JSONata expression, so the lookup keys will already match the lowercase map entries.

Applied to files:

  • comfy_api_nodes/util/__init__.py
📚 Learning: 2026-07-14T20:09:03.091Z
Learnt from: bigcat88
Repo: Comfy-Org/ComfyUI PR: 14928
File: comfy_api_nodes/nodes_sync_so.py:168-202
Timestamp: 2026-07-14T20:09:03.091Z
Learning: In the `comfy_api_nodes/` package, partner/API node `execute` implementations should keep the full submit → poll → status-check → download flow written inline within each node (even if similar logic appears across multiple nodes). This is an intentional repo convention to optimize per-node readability and independent editability, so during reviews you should generally not recommend refactoring this pattern into a shared helper function for these nodes (unless there’s a concrete correctness/security issue).

Applied to files:

  • comfy_api_nodes/util/__init__.py
📚 Learning: 2026-07-16T16:29:35.022Z
Learnt from: bigcat88
Repo: Comfy-Org/ComfyUI PR: 14958
File: comfy_api_nodes/nodes_heygen.py:554-558
Timestamp: 2026-07-16T16:29:35.022Z
Learning: When implementing ComfyUI API nodes in this repo, for any billable HTTP POST operations, follow the established policy: keep the existing default retry behavior. Do not add idempotency keys or disable retries. The rationale is to prevent failures from aborting the entire workflow; when reviewing new API nodes, check that POST billing requests preserve the default retry configuration and remain consistent with this policy.

Applied to files:

  • comfy_api_nodes/util/__init__.py
📚 Learning: 2026-08-04T18:49:57.785Z
Learnt from: bigcat88
Repo: Comfy-Org/ComfyUI PR: 15295
File: comfy_api_nodes/nodes_bfl.py:1037-1051
Timestamp: 2026-08-04T18:49:57.785Z
Learning: When consuming dictionaries produced by IO.Autogrow.Type, rely on their iteration order to match the configured template-slot order. This ordering is preserved by _expand_schema_for_dynamic, parse_class_inputs, and build_nested_inputs, so consumers should iterate the dictionary directly when processing dynamic slots.

Applied to files:

  • comfy_api_nodes/util/__init__.py
📚 Learning: 2026-08-11T17:33:31.657Z
Learnt from: bigcat88
Repo: Comfy-Org/ComfyUI PR: 15501
File: comfy_api_nodes/nodes_ltxv.py:213-217
Timestamp: 2026-08-11T17:33:31.657Z
Learning: When reviewing ComfyUI nodes that use IO.DynamicCombo, account for schema expansion by comfy_api/latest/_io.py::DynamicCombo._expand_schema_for_dynamic. Prompt validation in execution.py validates each resulting IO.Combo value against extra_info["options"] and rejects invalid values with value_not_in_list before execute() runs. Review validation logic against only the reachable option domain for closed IO.Combo.Input lists inside a DynamicCombo, unless the node provides another input path that bypasses prompt validation.

Applied to files:

  • comfy_api_nodes/util/__init__.py
📚 Learning: 2026-08-13T17:36:37.574Z
Learnt from: bigcat88
Repo: Comfy-Org/ComfyUI PR: 15579
File: comfy_api_nodes/nodes_bytedance.py:2115-2118
Timestamp: 2026-08-13T17:36:37.574Z
Learning: In ComfyUI API node implementations, treat saved `widgets_values` as positional. When renaming or changing the type of a widget input, do not rely on backend `execute()` to migrate legacy values, because prompt validation may reject the value before execution. Implement compatibility handling in the frontend or workflow/template migration layer so legacy workflows are converted before backend validation.

Applied to files:

  • comfy_api_nodes/util/__init__.py
🔇 Additional comments (1)
comfy_api_nodes/util/__init__.py (1)

21-21: LGTM!

Also applies to: 96-96


📝 Walkthrough

Walkthrough

The image conversion utility selects RGB for opaque images and RGBA for images with transparency when no mode is specified. Explicit conversion modes remain supported. The new padding utility adds opaque alpha channels before concatenation when image tensors have different channel counts. Gemini and Recraft normalize mixed-channel outputs. Recraft decodes remove-background results as RGBA. ByteDance decodes downloaded layers as RGBA. Unit tests cover these conversion and response paths.

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: API node images no longer receive an unnecessary opaque alpha channel.
Description check ✅ Passed The description directly explains the channel-preservation changes, affected nodes, tests, and excluded follow-up work.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@comfy_api_nodes/util/conversions.py`:
- Around line 36-37: Update get_image_from_response to inspect decoded image
channels before concatenating and promote RGB tensors to RGBA whenever any
response image includes alpha, ensuring all tensors share the same channel
count. Add a regression test covering a response with mixed RGB and RGBA image
parts.

In `@tests-unit/comfy_api_nodes_test/image_conversions_test.py`:
- Around line 43-48: Update test_palette_png_with_transparency_keeps_its_alpha
to set at least one image pixel to palette index 0 before encoding, then assert
that the corresponding tensor pixel has alpha 0.0 while a palette index 1 pixel
remains opaque. Retain the existing four-channel shape assertion and keep the
test focused on palette transparency.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5d6bb3fd-7fa4-464f-9a45-07d8ddd2fa9a

📥 Commits

Reviewing files that changed from the base of the PR and between 88fec4b and f056cc8.

📒 Files selected for processing (4)
  • comfy_api_nodes/nodes_gemini.py
  • comfy_api_nodes/nodes_recraft.py
  • comfy_api_nodes/util/conversions.py
  • tests-unit/comfy_api_nodes_test/image_conversions_test.py
📜 Review details
⏰ Context from checks skipped due to timeout. (9)
  • GitHub Check: test (ubuntu-latest)
  • GitHub Check: Run Pylint
  • GitHub Check: test (windows-latest)
  • GitHub Check: test (windows-2022)
  • GitHub Check: test
  • GitHub Check: test (macos-latest)
  • GitHub Check: test (ubuntu-latest)
  • GitHub Check: test (macos-latest)
  • GitHub Check: Run Pylint
🧰 Additional context used
📓 Path-based instructions (6)
**/*

📄 CodeRabbit inference engine (AGENTS.md)

**/*: Keep changes small, direct, and limited to the narrowest necessary code path and smallest number of files.
Prefer practical fixes, minimal dependencies, and existing repository patterns; remove obsolete, dead, unreachable, or unused code.
Preserve existing APIs, node names, model-loading behavior, file layout, and workflow compatibility unless replacement is explicitly intended.
Core ComfyUI must not add outbound internet requests, telemetry, tracking, reporting, remote configuration, or background network activity. User-authorized model downloads are limited to the requested artifact and must exclude telemetry and unrelated metadata.

Files:

  • comfy_api_nodes/nodes_gemini.py
  • comfy_api_nodes/nodes_recraft.py
  • comfy_api_nodes/util/conversions.py
  • tests-unit/comfy_api_nodes_test/image_conversions_test.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Keep state and capability flags on the object that owns the behavior. Prefer explicit parent-owned attributes over probing child objects with getattr; use child checks only when the child owns the delegated behavior.
Preserve shared method signatures, argument order, return shapes, side effects, and error behavior unless every affected caller and interface is intentionally updated.
Do not add unused compatibility parameters, flags, attributes, constructor options, or model-specific options to shared helpers; keep one-off behavior at the integration boundary.
Normalize third-party return conventions at integration boundaries so core code receives the expected type and shape; avoid undocumented caller-side unwrapping.
Do not add torch.no_grad, torch.inference_mode, or inference-mode wrappers. Do not add model freeze/unfreeze toggles; only disable globally enabled inference mode when a training path requires gradients.
Remove inference-only training behavior such as dropout while preserving checkpoint and state-dict compatibility; use nn.Identity when deleting a module would alter keys or ordering.
Keep imports at module scope except established optional-backend probes or imports required to avoid cycles; avoid unnecessary try/except blocks and use specific exceptions with useful fallbacks.
Do not add workarounds for unsupported library versions, especially PyTorch exception-and-float-cast retries, unless a comment names the exact versions still requiring them.
Let unsupported model formats, invalid quantization metadata, and bad states fail with clear errors instead of silently degrading output.
Match local style, keep comments sparse and useful, and remove comments that merely restate obvious code.
Treat dtype, device placement, VRAM use, and offloading as correctness concerns across CPU, CUDA, ROCm, MPS, DirectML, XPU, NPU, and low-VRAM environments.
Prefer existing ComfyUI and Comfy Kitchen operations, quantization helpers, cast/offload helpe...

Files:

  • comfy_api_nodes/nodes_gemini.py
  • comfy_api_nodes/nodes_recraft.py
  • comfy_api_nodes/util/conversions.py
  • tests-unit/comfy_api_nodes_test/image_conversions_test.py
**/*.{py,json}

📄 CodeRabbit inference engine (AGENTS.md)

Treat legacy combo, io.Combo, and io.DynamicCombo values affecting filesystem access as untrusted; revalidate them at load/save boundaries with folder_paths, containment checks, or fixed allowlists.

Files:

  • comfy_api_nodes/nodes_gemini.py
  • comfy_api_nodes/nodes_recraft.py
  • comfy_api_nodes/util/conversions.py
  • tests-unit/comfy_api_nodes_test/image_conversions_test.py
**/*.{py,md,txt,json}

📄 CodeRabbit inference engine (AGENTS.md)

Keep warning and info messages short and actionable, remove noisy or misleading logging, and make documentation edits concise, factual, and tied to changed behavior.

Files:

  • comfy_api_nodes/nodes_gemini.py
  • comfy_api_nodes/nodes_recraft.py
  • comfy_api_nodes/util/conversions.py
  • tests-unit/comfy_api_nodes_test/image_conversions_test.py
**

⚙️ CodeRabbit configuration file

**: IMPORTANT: Only comment on issues directly introduced by this PR's code changes.
Treat AGENTS.md as mandatory repository policy, not optional style guidance.
Flag PR changes that violate AGENTS.md even when the code is otherwise functional.
In particular, enforce architecture boundaries, dtype/device/memory rules,
interface contracts, import style, no unnecessary try/except blocks, no inline
imports, no outbound internet paths in core ComfyUI, and narrow scoped fixes.
Prefer direct findings over suggestions when a rule is violated. Only ignore
AGENTS.md when it clearly conflicts with a newer explicit maintainer instruction
in the PR.
Do NOT flag pre-existing issues in code that was merely moved, re-indented,
de-indented, or reformatted without logic changes. If code appears in the diff
only due to whitespace or structural reformatting (e.g., removing a with: block),
treat it as unchanged. Contributors should not feel obligated to address
pre-existing issues outside the scope of their contribution.

Files:

  • comfy_api_nodes/nodes_gemini.py
  • comfy_api_nodes/nodes_recraft.py
  • comfy_api_nodes/util/conversions.py
  • tests-unit/comfy_api_nodes_test/image_conversions_test.py
comfy_api_nodes/**

⚙️ CodeRabbit configuration file

comfy_api_nodes/**: Third-party API integration nodes. Focus on:

  • No hardcoded API keys or secrets
  • Proper error handling for API failures (timeouts, rate limits, auth errors)
  • Correct Pydantic model usage
  • Security of user data passed to external APIs

Files:

  • comfy_api_nodes/nodes_gemini.py
  • comfy_api_nodes/nodes_recraft.py
  • comfy_api_nodes/util/conversions.py
🧠 Learnings (6)
📚 Learning: 2026-02-21T14:01:41.482Z
Learnt from: pythongosssss
Repo: Comfy-Org/ComfyUI PR: 12555
File: comfy_extras/nodes_glsl.py:719-724
Timestamp: 2026-02-21T14:01:41.482Z
Learning: In PyOpenGL, bare Python scalars can be accepted for 1-element array parameters by NumberHandler. This means you can pass an int/float directly to OpenGL texture deletion (e.g., glDeleteTextures(tex)) without wrapping in a list. Verify function-specific expectations and ensure types match what the OpenGL call expects; use explicit lists only when the API requires an array.

Applied to files:

  • comfy_api_nodes/nodes_gemini.py
  • comfy_api_nodes/nodes_recraft.py
  • comfy_api_nodes/util/conversions.py
  • tests-unit/comfy_api_nodes_test/image_conversions_test.py
📚 Learning: 2026-04-18T16:55:46.724Z
Learnt from: bigcat88
Repo: Comfy-Org/ComfyUI PR: 13465
File: comfy_api_nodes/nodes_bytedance.py:1496-1506
Timestamp: 2026-04-18T16:55:46.724Z
Learning: In `comfy_api_nodes` Python async node implementations (e.g., `async def execute`), synchronous CPU/IO-heavy helpers (such as video/audio trim/resize and base64/MP3 conversion) may be called directly without offloading to a thread executor (e.g., `asyncio.to_thread`). Treat this as an existing, broader refactor concern rather than a new PR regression: if the PR does not introduce additional synchronous blocking calls, reviewers should not flag it as a new issue. However, if the PR adds new synchronous CPU/IO work inside `async def execute`, prefer offloading with `asyncio.to_thread` (or an equivalent background executor) to avoid blocking the event loop.

Applied to files:

  • comfy_api_nodes/nodes_gemini.py
  • comfy_api_nodes/nodes_recraft.py
  • comfy_api_nodes/util/conversions.py
📚 Learning: 2026-05-07T17:59:26.050Z
Learnt from: bigcat88
Repo: Comfy-Org/ComfyUI PR: 13753
File: comfy_api_nodes/nodes_gemini.py:1148-1157
Timestamp: 2026-05-07T17:59:26.050Z
Learning: In ComfyUI node implementations under `comfy_api_nodes/`, when building JSONata expressions that use `IO.PriceBadge` for `$lookup` against a price map keyed in lowercase, do not add an explicit `$lowercase()` around widget values (e.g., combo options like "1K", "2K", "4K"). The ComfyUI frontend automatically lowercases widget values before evaluating the JSONata expression, so the lookup keys will already match the lowercase map entries.

Applied to files:

  • comfy_api_nodes/nodes_gemini.py
  • comfy_api_nodes/nodes_recraft.py
  • comfy_api_nodes/util/conversions.py
📚 Learning: 2026-07-14T20:09:03.091Z
Learnt from: bigcat88
Repo: Comfy-Org/ComfyUI PR: 14928
File: comfy_api_nodes/nodes_sync_so.py:168-202
Timestamp: 2026-07-14T20:09:03.091Z
Learning: In the `comfy_api_nodes/` package, partner/API node `execute` implementations should keep the full submit → poll → status-check → download flow written inline within each node (even if similar logic appears across multiple nodes). This is an intentional repo convention to optimize per-node readability and independent editability, so during reviews you should generally not recommend refactoring this pattern into a shared helper function for these nodes (unless there’s a concrete correctness/security issue).

Applied to files:

  • comfy_api_nodes/nodes_gemini.py
  • comfy_api_nodes/nodes_recraft.py
  • comfy_api_nodes/util/conversions.py
📚 Learning: 2026-07-16T16:29:35.022Z
Learnt from: bigcat88
Repo: Comfy-Org/ComfyUI PR: 14958
File: comfy_api_nodes/nodes_heygen.py:554-558
Timestamp: 2026-07-16T16:29:35.022Z
Learning: When implementing ComfyUI API nodes in this repo, for any billable HTTP POST operations, follow the established policy: keep the existing default retry behavior. Do not add idempotency keys or disable retries. The rationale is to prevent failures from aborting the entire workflow; when reviewing new API nodes, check that POST billing requests preserve the default retry configuration and remain consistent with this policy.

Applied to files:

  • comfy_api_nodes/nodes_gemini.py
  • comfy_api_nodes/nodes_recraft.py
  • comfy_api_nodes/util/conversions.py
📚 Learning: 2026-08-04T18:49:57.785Z
Learnt from: bigcat88
Repo: Comfy-Org/ComfyUI PR: 15295
File: comfy_api_nodes/nodes_bfl.py:1037-1051
Timestamp: 2026-08-04T18:49:57.785Z
Learning: When consuming dictionaries produced by IO.Autogrow.Type, rely on their iteration order to match the configured template-slot order. This ordering is preserved by _expand_schema_for_dynamic, parse_class_inputs, and build_nested_inputs, so consumers should iterate the dictionary directly when processing dynamic slots.

Applied to files:

  • comfy_api_nodes/nodes_gemini.py
  • comfy_api_nodes/nodes_recraft.py
  • comfy_api_nodes/util/conversions.py
🔇 Additional comments (4)
comfy_api_nodes/util/conversions.py (1)

19-26: LGTM!

tests-unit/comfy_api_nodes_test/image_conversions_test.py (1)

1-40: LGTM!

Also applies to: 51-54

comfy_api_nodes/nodes_gemini.py (1)

236-236: LGTM!

comfy_api_nodes/nodes_recraft.py (1)

998-998: LGTM!

Comment thread comfy_api_nodes/util/conversions.py
Comment thread tests-unit/comfy_api_nodes_test/image_conversions_test.py
@christian-byrne

Copy link
Copy Markdown
Contributor Author

Both CodeRabbit findings addressed in 400b041.

Mixed channel counts across image parts — real, and new: before this PR every part decoded to RGBA so torch.cat could not disagree. get_image_from_response now pads the narrower parts with an opaque alpha before concatenating, matching what ImageBatch does at nodes.py:1958-1965. Regression test in tests-unit/comfy_api_nodes_test/gemini_response_images_test.py covers an RGB + RGBA response and checks the padded part comes out opaque while the transparent one is preserved.

Palette test had no transparent pixel — correct, the image was filled with index 1 while transparency marked index 0. Fixed, and it now asserts alpha 0.0 on the transparent index and 1.0 on the opaque one.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 7, 2026
bytesio_to_image_tensor converted every downloaded image to RGBA, so nodes
whose API returns no transparency still emitted a 4 channel IMAGE. Keep the
alpha when the decoded image has one, stay RGB when it does not.
A multi part response can now decode to a mix of RGB and RGBA, which
torch.cat rejects. Widen the narrower parts with an opaque alpha, the same
way ImageBatch does.
@christian-byrne
christian-byrne force-pushed the fix/api-nodes-preserve-alpha branch from 230be4e to f64722d Compare August 10, 2026 20:57
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 14, 2026
Signed-off-by: bigcat88 <bigcat88@icloud.com>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 14, 2026
@bigcat88 bigcat88 changed the title Stop adding an opaque alpha channel to API node images [Partner Nodes] Stop adding an opaque alpha channel to API node images Aug 14, 2026
bigcat88
bigcat88 previously approved these changes Aug 14, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 14, 2026
@bigcat88
bigcat88 dismissed stale reviews from coderabbitai[bot] and themself via 3c92268 August 14, 2026 11:36
@bigcat88
bigcat88 force-pushed the fix/api-nodes-preserve-alpha branch from 33d9813 to 3c92268 Compare August 14, 2026 11:36
Signed-off-by: bigcat88 <bigcat88@icloud.com>
@bigcat88
bigcat88 force-pushed the fix/api-nodes-preserve-alpha branch from 3c92268 to d2a99f6 Compare August 14, 2026 11:48
@bigcat88
bigcat88 merged commit a9ab2b6 into master Aug 15, 2026
23 checks passed
@bigcat88
bigcat88 deleted the fix/api-nodes-preserve-alpha branch August 15, 2026 17:27
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants