ComfyUI > Nodes > TrentNodes > First Valid

ComfyUI Node: First Valid

Class Name

FirstValid

Category
Trent/Flow
Author
TrentHunter82 (Account age: 0days)
Extension
TrentNodes
Latest Updated
2026-03-20
Github Stars
0.03K

How to Install TrentNodes

Install this extension via the ComfyUI Manager by searching for TrentNodes
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter TrentNodes in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

First Valid Description

Evaluates inputs in order, returning the first valid one, optimizing AI art workflows.

First Valid:

The FirstValid node is a versatile tool designed to streamline workflows by providing a fallback mechanism in scenarios where multiple input sources are available. Its primary function is to evaluate a series of inputs in a specified priority order and return the first input that is considered "truthy," meaning it holds a valid or meaningful value. This node is particularly beneficial in situations where you have primary, secondary, and tertiary sources of data, such as images, prompts, or parameters, and you want to ensure that the most relevant and available data is used without unnecessary processing. By employing lazy evaluation, the FirstValid node efficiently skips over subsequent inputs once a valid one is found, thereby optimizing performance and reducing computational overhead. This makes it an essential component for creating robust and efficient AI art generation pipelines, where fallback options are crucial for maintaining workflow continuity.

First Valid Input Parameters:

first

The first parameter is the highest priority input for the FirstValid node. It is the first input to be evaluated for truthiness, meaning the node will check if this input holds a valid or meaningful value before considering others. This parameter is crucial because if it is truthy, the node will immediately return it, bypassing the need to evaluate the other inputs. There are no specific minimum, maximum, or default values for this parameter, as it can accept any type of input. The key is that it should be the most preferred or likely to be valid input in your workflow.

second

The second parameter serves as the secondary input, evaluated only if the first parameter is found to be falsy. This parameter acts as a backup to the primary input, ensuring that the node can still produce a valid output even if the first input is unavailable or invalid. Like the first parameter, it does not have specific constraints on its values, but it should be a viable alternative to the primary input.

third

The third parameter is the tertiary input, used as a fallback option if both the first and second inputs are falsy. This parameter ensures that the node can still function and provide an output even when the primary and secondary inputs fail. It is the least prioritized input but plays a critical role in maintaining the robustness of the workflow by providing a last-resort option.

First Valid Output Parameters:

output

The output parameter is the result of the FirstValid node's evaluation process. It contains the first truthy input value found among the first, second, and third parameters. If none of the inputs are truthy, the output will be an ExecutionBlocker, indicating that all inputs were falsy and the node could not produce a valid result. This output is essential for determining the success of the node's operation and ensuring that the workflow can proceed with the most relevant data available.

First Valid Usage Tips:

  • Prioritize your inputs carefully, placing the most likely valid or preferred data source as the first parameter to maximize efficiency and reduce unnecessary evaluations.
  • Use the FirstValid node in scenarios where you have multiple potential data sources, such as different image resolutions or prompt variations, to ensure that your workflow remains flexible and resilient to missing or invalid data.

First Valid Common Errors and Solutions:

All inputs are falsy

  • Explanation: This error occurs when none of the provided inputs (first, second, or third) are truthy, resulting in the node returning an ExecutionBlocker.
  • Solution: Ensure that at least one of the inputs is likely to be valid. You may need to check the data sources or adjust the priority of inputs to ensure that a truthy value is available.

Invalid input type

  • Explanation: This error might occur if the inputs provided are not compatible with the node's expected input types, leading to unexpected behavior.
  • Solution: Verify that the inputs are of the correct type and format. Ensure that they are capable of being evaluated for truthiness, such as non-empty strings, non-zero numbers, or valid objects.

First Valid Related Nodes

Go back to the extension to check out more related nodes.
TrentNodes
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

First Valid