Nodes/image_control/abyz22_FirstNonNull
ComfyUI Node

abyz22_FirstNonNull

The fallback that keeps optional branches alive

By abyz22·Created 3 years ago·Updated 2 years ago· 17
abyz22_FirstNonNull
  • value1
  • value2
  • VALUE

ComfyUI is full of nodes that accept optional inputs, and "what if that optional input is empty" is a whole genre of silent failure. abyz22_FirstNonNull is a tiny two-input fallback: give it two values, and it hands you whichever is not empty, defaulting to the first. That's the entire job. No models, no math, no state - it's a wiring convenience that saves you from conditional-node spaghetti.

It's the simplest node in abyz22/image_control, the Impact Pack fork. Given the pack's adult body-editing focus, this is very much the "comes along for the ride" utility - and honestly, the most reusable thing in the repo.

What it does

  • value1 - checked first.
  • value2 - used if value1 is None.
  • VALUE - the winner, passed through with its original type.

Both inputs are wildcard-typed, so it works with conditioning, images, strings, latents, whatever. The one hard rule: if both are empty it raises an error - "Atleast One Value Input Expected" - instead of silently returning nothing. That's the correct failure mode for a fallback node, so don't treat it as a bug; it's telling you your graph is missing both branches.

How it works

The implementation is one if/else on None checks. The subtle part is what counts as "empty": it checks for None, not for falsy values. An empty string "" and a zero-length list are not None, so they'd pass through as the "winner." If your optional branch produces an empty string when it's inactive, FirstNonNull will happily return that empty string and you'll be confused why your "fallback" didn't kick in. For the fallback pattern to work, the upstream nodes have to produce actual None when they're off - most ComfyUI optional inputs do, but verify the specific node feeding you.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/abyz22/image_control

or ComfyUI Manager → "image_control", restart ComfyUI. The pack's install pulls openpyxl, pytorch-lightning, and kornia.

When to reach for it

The classic spot: a branch that only exists sometimes - say, an upscaler that's only wired in for certain images - feeding a node that needs something. FirstNonNull between the optional branch and its consumer means the graph runs with or without the branch present. It's also handy right after a bypass node (abyz22_bypass, same pack): a bypassed branch often yields None, and FirstNonNull catches that and substitutes the straight path. It's a two-node combination that does for conditional wiring what a || does in code. Just remember the None-vs-falsy caveat above and it'll never surprise you.

Categoryabyz22

Inputs (2)

NameTypeDefaultDescription
value1opt*
value2opt*

Outputs (1)

NameTypeDescription
VALUE*