FD First Non Null
Use this if it's there, otherwise fall back to that
- value1
- value2
- VALUE
Feidorian_FirstNonNull (FD First Non Null) is a graceful fallback in node form. It takes two optional inputs, value1 and value2, and outputs whichever of them is not None. First non-null wins. If both are connected, you get value1; if value1 is empty or unconnected, you get value2; if both are missing, it raises an exception telling you at least one value is expected.
The trick that makes it useful is how ComfyUI treats unconnected optional inputs: they arrive as None. So this node's real behaviour is "prefer what's wired in, fall back to what's wired in behind it." That's a surprising amount of power for something so simple.
Why you'd reach for it. Building a workflow where a value sometimes exists and sometimes doesn't. A prompt that a batch loader sometimes supplies via metadata and otherwise should default to a literal you typed. A model or VAE that's optional in one graph shape and required in another. An image that appears only when a switch routes a branch - chain FirstNonNull after the switch and the downstream node always gets something instead of erroring on a missing wire. It's the "default if absent" pattern that ComfyUI doesn't give you natively.
Inputs and output. Both inputs are optional and any-type (value1, value2), one output VALUE (*). Because the types are wildcards, this works on strings, images, conditioning, latents - whatever your branch carries. That's also the one thing to be careful about: the node won't check that value1 and value2 are the same kind of thing, so make sure your fallback is actually compatible with what the downstream node expects.
The honest take. This is a genuinely useful little logic node, and the "first non-null" pattern is worth keeping in your head even if you use a different pack's equivalent. Where people get burned: the both-None exception. Wire nothing into either input and run, and the node throws "Atleast One Value Input Expected" - it's a loud failure by design, but it looks like a crash if you didn't expect it. Also worth noting: a connected input that produces an empty string is not None, so an empty prompt string will be "used" rather than skipped. If you want empty-string fallback, this isn't the node for that.
The pack is archived, so this behavior is frozen. Fine - the logic is simple enough that nothing really needs changing.
Install. ComfyUI Manager (search "feidorian-ComfyNodes"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/Feidorian/feidorian-ComfyNodes
Restart ComfyUI and it'll be under the "FD" prefix. No dependencies, no models - it's pure Python, one of the painless installs in an otherwise frozen pack.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| value1opt | * | — | |
| value2opt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| VALUE | * | — |