Nodes/honda-nodes/πŸ“‹ Array Is Empty
ComfyUI Node

πŸ“‹ Array Is Empty

The check that stops an empty list from wrecking a run

By AvarayΒ·Created 14 days agoΒ·Updated 12 days agoΒ· 0
πŸ“‹ Array Is Empty
    • Result
    • Count
    β—„arrayβ€”β–Ί

    A boolean, and a little insurance

    Array Is Empty emits one BOOLEAN: True if the list has nothing in it, False otherwise. That's the whole node. The reason to care is that the empty list is the failure mode that ruins unattended runs - a folder that turned out to be empty, a πŸ“‹ Array Filter whose glob matched nothing, a list that got consumed by an earlier slice. Downstream, an empty string flows into a prompt, a filename, or a πŸ“‚ Delete File path, and the run either produces garbage or stops with an error fifty nodes later.

    Catching it here, at the top, is the difference between "the batch finished and produced three images" and "the batch finished and produced three images plus one mystery crash".

    How it works, and the detail that matters

    It splits on newlines, discards anything that's blank after stripping whitespace, and returns whether the remainder is empty - plus that remainder's Count. So a text field containing nothing but newlines and spaces counts as empty. That's the sane reading, and it differs from a naive len(split()) which would tell you that a single \n is a two-item list. The author got this right; you don't have to think about it.

    Two outputs, in opposite directions: Result (BOOLEAN) and Count (INT). The boolean is the interesting one because it's what feeds conditional logic, but Count is the one you'll actually read while debugging - Result = True, Count = 0 is a much clearer diagnostic than a red node.

    Where the boolean goes

    Honest answer: ComfyUI's native conditional story is thin, so a BOOLEAN is most useful in two places.

    First, as a guard wired into a switch. The plumbing layer of the ComfyUI ecosystem is full of A/B and fallback switches - the pattern where a boolean picks between "the real value" and "a known-good placeholder". Array Is Empty feeding a switch that substitutes a default prompt when the bank came back empty is a two-node fix for a whole class of bad runs.

    Second, as a signal you read. Wire it to a preview or a console print and you get a cheap assertion at the start of the graph: "is there anything to do?" For pipelines that run overnight, that's worth more than it sounds.

    What it is not is a loop terminator. There's no native while-loop in ComfyUI, so "stop when the list is empty" is not something this boolean can do on its own - see πŸ“‹ Array For Each's Is Last output for the version of that idea the pack actually supports.

    Inputs

    Array, socket-only (force_input, like the rest of the group - no pasting). Wire in πŸ“‹ Array From Text, πŸ“‚ List Files, πŸ“‹ Array Filter, πŸ“‚ Read File, anything that produces the newline-separated format.

    That's the entire input list. No trim toggle, no options - the node always treats whitespace-only lines as absent, which I'd argue is the correct amount of configurability for a check like this.

    Install

    Manager is easiest: Extensions β†’ Node Pack β†’ search "Honda Nodes" β†’ Install β†’ restart ComfyUI. Manually:

    cd ComfyUI/custom_nodes
    git clone --depth 1 https://github.com/Avaray/honda-nodes.git
    cd honda-nodes
    python install.py   # use ComfyUI's python; portable Windows: ..\..\..\python_embeded\python.exe install.py
    

    The installer fetches the jq and ime CLIs for the pack's JSON and metadata nodes; this node needs neither. What it does need is a ComfyUI build at 0.38.0 or newer, because the pack is V3 schema only and ships no NODE_CLASS_MAPPINGS to fall back on.

    Common issues

    It says False and the list looks empty. Something on a "blank" line isn't whitespace. Ordinary spaces and tabs are stripped before the check, so they can't fool it - but a zero-width space or other invisible character pasted in from a web page survives .strip() and makes an empty-looking line real. Select the blank line and move the caret through it; if it doesn't go from end to end in one keystroke, there's a character hiding there.

    It says True but the workflow still ran and errored. The boolean guarded a value, not the branch. In ComfyUI, wiring a boolean into a switch routes data; it doesn't stop nodes from executing. Build the switch so the empty branch resolves to something valid rather than to nothing.

    Nothing evaluates. Same rule as all non-output nodes in this pack: no downstream output node, no execution.

    Category⚑️ Honda Nodes/πŸ“‹ Array

    Inputs (1)

    NameTypeDefaultDescription
    arraySTRINGNewline-separated array string.

    Outputs (2)

    NameTypeDescription
    ResultBOOLEANβ€”
    CountINTβ€”