Nodes/ComfyUI-KYNode/First NOT NONE
ComfyUI Node

First NOT NONE

A fallback chain, and a real gotcha with the number zero

By yorkane·Created 2 years ago·Updated 6 months ago· 10
First NOT NONE
  • Fallback
  • A
  • B
  • C
  • D
  • out
  • is_blocked
force_fallbacktrue
block_if_all_emptytrue

The pattern this node implements is familiar from plenty of programming languages: a coalesce chain. Give it several candidate values in priority order, and it hands back the first one that actually has content, falling back to a guaranteed default if none of them do. Useful anywhere a workflow has several possible sources for a value - a user override, a previous node's output, a hardcoded default - and you want whichever one is actually populated, checked in a specific order.

What counts as "empty"

The node's own description spells this out directly, and it's more thorough than a simple None check: it treats as empty an empty list, dictionary, or tuple; an empty string; the number 0 (as float, int, or complex); and an empty tensor. That list is worth reading twice, because the one that catches people is 0 counting as empty. If you're piping a genuine numeric value through this node - say, a coordinate, a frame index, or any count where zero is a legitimate, meaningful answer - this node will treat that 0 the same as if nothing had been wired in at all, and skip past it to the next candidate or the fallback. This node is built for "did something meaningfully get set," not strict "is this technically None," and that distinction matters most exactly at zero.

Inputs and outputs

One required input: Fallback, wildcard-typed - the guaranteed value the node falls back to if nothing else qualifies. Optional inputs A, B, C, D (all wildcard) are the candidates, checked in that order ahead of the fallback.

Two more optional booleans, force_fallback and block_if_all_empty, both defaulting to true. Neither one gets a tooltip or further explanation in the schema, so take their names as a starting point rather than a guarantee - force_fallback reads as a way to make Fallback win regardless of whether AD have values, and block_if_all_empty reads as gating whether the graph is allowed to continue past this node if literally everything, including Fallback, comes back empty. If your output isn't matching what you expected from the priority order alone, these two are the first things to toggle and test directly.

Two outputs: out (the winning value) and is_blocked (a BOOLEAN - almost certainly tied to block_if_all_empty, reporting whether this node halted the graph).

Installing it

ComfyUI Manager: search ComfyUI-KYNode, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/yorkane/ComfyUI-KYNode

Restart ComfyUI. No external dependencies - pure logic on whatever values you wire in.

Common issues

The zero-counts-as-empty behavior above is the one to internalize before you build around this node - test it deliberately with a genuine 0 in one of your candidate slots if your pipeline ever legitimately produces one, rather than discovering the fallback silently won in production.

Since A through D are all optional and wildcard-typed, it's easy to leave one disconnected by accident and have the node quietly skip past it - if a candidate you thought was wired in isn't showing up in the result, double-check the actual connection, not just the node's logic.

This pack's KY_isNone shares the same "None or empty" vocabulary and is worth pairing with this node - use KY_isNone upstream if you need to inspect or gate on a single value's emptiness before it ever reaches this fallback chain.

CategoryKYNode/Utils

Inputs (7)

NameTypeDefaultDescription
Fallback*
Aopt*
Bopt*
Copt*
Dopt*
force_fallbackoptBOOLEANtrue
block_if_all_emptyoptBOOLEANtrue

Outputs (2)

NameTypeDescription
out*
is_blockedBOOLEAN