First Non Empty Or Default¶
Class: FirstNonEmptyOrDefaultBlockV1
Merge alternative execution branches by selecting the first non-empty value from multiple data inputs, or returning a default value if all inputs are empty, enabling conditional execution merging, empty value handling, and structured output construction workflows where data from different branches needs to be combined or fallback values need to be provided for missing data.
How This Block Works¶
This block merges data from multiple sources (typically from different conditional execution branches) by selecting the first available non-empty value, ensuring outputs are always present for downstream processing. The block:
- Receives a list of data references and an optional default value:
- Takes multiple data inputs as a list of selectors (minimum 1 required)
- Each selector can reference outputs from different workflow steps or branches
- Receives a default value to use when all inputs are empty
- Processes inputs in order:
- Iterates through the data inputs in the order they are provided
- Checks each input value to determine if it is non-empty (not None)
- Stops at the first non-empty value encountered
- Selects first non-empty value:
- Returns the first non-empty value from the list if found
- This allows prioritizing certain data sources over others
- Order matters: earlier inputs have priority over later ones
- Falls back to default if all empty:
- If all inputs in the list are empty (None), returns the configured default value
- Ensures the output is never None, making it safe for downstream blocks
- Default value can be any type (string, number, object, null, etc.)
- Handles empty values:
- This block accepts empty values (None) from conditional execution
- Unlike most blocks that skip processing when inputs are None, this block processes them
- Converts potentially empty inputs into a guaranteed non-empty output
- Returns merged output:
- Outputs the selected value (first non-empty or default)
- Output is always non-None, ensuring compatibility with blocks that don't accept empty values
- Enables structured output construction even when some execution branches produce no data
This block is essential for merging alternative execution branches in workflows with conditional logic. When different branches of a workflow can produce data (e.g., one branch processes data if condition A is true, another if condition B is true), this block allows you to combine those branches by selecting the first available result, ensuring your workflow always produces a valid output.
Common Use Cases¶
- Merging Conditional Branches: Merge outputs from alternative conditional execution branches into a single value (e.g., merge results from different if-else branches, combine alternative processing paths, unify conditional branch outputs), enabling conditional execution merging workflows
- Empty Value Handling: Handle potentially empty values from filtering or conditional execution by providing fallback defaults (e.g., handle filtered data with defaults, provide fallbacks for conditional branches, ensure non-empty outputs from optional steps), enabling robust empty value handling workflows
- Structured Output Construction: Ensure workflow outputs always have values even when some execution paths don't produce data (e.g., construct consistent output structures, guarantee output field presence, build structured responses with defaults), enabling structured output construction workflows
- Priority-Based Selection: Select data from multiple sources based on priority order (e.g., prefer primary source over fallback, select best available data source, prioritize certain processing results), enabling priority-based data selection workflows
- Fallback Values: Provide fallback values when primary data sources are unavailable (e.g., use default values when data missing, provide fallbacks for empty results, ensure downstream compatibility), enabling fallback value workflows
- Output Normalization: Normalize outputs to ensure they're always present and non-empty (e.g., normalize optional outputs, ensure consistent output format, guarantee output availability), enabling output normalization workflows
Connecting to Other Blocks¶
This block receives multiple data inputs and produces a single merged output:
- After conditional execution blocks (ContinueIf, DetectionsFilter, etc.) to merge alternative branch outputs (e.g., merge if-else branch results, combine conditional paths, unify branch outputs), enabling conditional-to-merge workflows
- Before blocks that don't accept empty values to ensure inputs are always present (e.g., ensure non-empty inputs, provide fallbacks for empty data, guarantee input availability), enabling merge-to-processing workflows
- In workflow outputs to construct structured outputs with guaranteed field presence (e.g., build consistent outputs, ensure output completeness, create structured responses), enabling merge-to-output workflows
- After filtering blocks to handle cases where filters remove all data (e.g., provide defaults for filtered data, handle empty filter results, ensure output availability), enabling filter-to-merge workflows
- Before data storage blocks to ensure stored data is always present (e.g., store with defaults, ensure data completeness, provide fallback storage values), enabling merge-to-storage workflows
- Between alternative processing paths to combine results from different processing strategies (e.g., merge alternative processing results, combine different model outputs, unify processing strategies), enabling alternative-to-merge workflows
Requirements¶
This block requires at least one data input reference (can accept multiple). The block accepts empty values (None), allowing it to process data from conditional execution branches. The default parameter is optional (defaults to None) and specifies the fallback value when all inputs are empty. Data inputs are processed in order, with the first non-empty value being selected. If all inputs are empty, the default value is returned. The output is always non-None, ensuring compatibility with blocks that don't accept empty values. This block is essential for merging alternative execution branches and ensuring structured outputs are always complete.
Type identifier¶
Use the following identifier in step "type" field: roboflow_core/first_non_empty_or_default@v1to add the block as
as step in your workflow.
Properties¶
| Name | Type | Description | Refs |
|---|---|---|---|
name |
str |
Enter a unique identifier for this step.. | ❌ |
default |
Any |
Default value to return when all data inputs are empty (None). This ensures the output is always non-None, making it safe for downstream blocks that don't accept empty values. The default can be any type: string (e.g., 'empty', 'N/A'), number (e.g., 0, -1), object (e.g., {}, []), null, or any other value. If not specified, defaults to None. Use this to provide fallback values when conditional execution branches or filtering removes all data, or to ensure structured outputs always have values.. | ❌ |
The Refs column marks possibility to parametrise the property with dynamic values available
in workflow runtime. See Bindings for more info.
Available Connections¶
Compatible Blocks
Check what blocks you can connect to First Non Empty Or Default in version v1.
- inputs:
Keypoint Visualization,Keypoint Detection Model,Twilio SMS/MMS Notification,OPC UA Writer Sink,Perception Encoder Embedding Model,Qwen 3.6 API,SIFT Comparison,Grid Visualization,SAM 3,Object Detection Model,Llama 3.2 Vision,PLC Writer,JSON Parser,Absolute Static Crop,Distance Measurement,Roboflow Visual Search Classifier,Velocity,Image Threshold,Polygon Zone Visualization,CogVLM,BoT-SORT Tracker,MQTT Writer,Contrast Equalization,Google Gemini,Detections List Roll-Up,OCR Model,GLM-OCR,Background Subtraction,Contrast Enhancement,Reference Path Visualization,Twilio SMS Notification,Instance Segmentation Model,Google Gemma API,Mask Edge Snap,Detections Filter,Detections Classes Replacement,Detections Merge,PTZ Tracking (ONVIF),VLM As Detector,Florence-2 Model,Dynamic Crop,Halo Visualization,Image Blur,LMM,SAM 3 Interactive,Seg Preview,SAM 3,Ellipse Visualization,OpenAI,Byte Tracker,Florence-2 Model,Line Counter,LMM For Classification,Time in Zone,Cache Set,Path Deviation,OpenAI,Data Aggregator,Instance Segmentation Model,Semantic Segmentation Model,Event Writer,Time in Zone,Single-Label Classification Model,Keypoint Detection Model,Google Gemma,Byte Tracker,Buffer,Slack Notification,Heatmap Visualization,SORT Tracker,Semantic Segmentation Model,Email Notification,Circle Visualization,Perspective Correction,Camera Focus,Byte Tracker,Crop Visualization,Detections Consensus,Polygon Visualization,Keypoint Detection Model,Line Counter,ByteTrack Tracker,Multi-Label Classification Model,Detections Combine,Stability AI Inpainting,OpenAI-Compatible LLM,SAM 3,Object Detection Model,VLM As Classifier,PLC ModbusTCP,Google Gemini,Image Slicer,Roboflow Vision Events,Detections Transformation,Multi-Label Classification Model,Size Measurement,Qwen3.5,Local File Sink,Delta Filter,Object Detection Model,Inner Workflow,SAM3 Video Tracker,Dot Visualization,QR Code Detection,Line Counter Visualization,Expression,Depth Estimation,Time in Zone,Instance Segmentation Model,Stitch OCR Detections,PP-OCR,Blur Visualization,Clip Comparison,EasyOCR,Anthropic Claude,PLC EthernetIP,Segment Anything 2 Model,CSV Formatter,Color Visualization,Per-Class Confidence Filter,Qwen2.5-VL,Qwen3-VL,Dynamic Zone,Image Convert Grayscale,Motion Detection,Stitch OCR Detections,Rate Limiter,Single-Label Classification Model,Qwen 3.5 API,Current Time,Icon Visualization,Trace Visualization,Cache Get,PLC Reader,Model Comparison Visualization,Camera Focus,QR Code Generator,Google Gemini,Detections Stitch,Image Stack,Instance Segmentation Model,Qwen-VL,Mask Visualization,MoonshotAI Kimi,Microsoft SQL Server Sink,Text Display,Gaze Detection,Stability AI Image Generation,Continue If,Google Vision OCR,Webhook Sink,OpenAI,VLM As Detector,Identify Outliers,Cosine Similarity,Pixelate Visualization,Stitch Images,Detection Offset,Switch Case,Classification Label Visualization,S3 Sink,MoonshotAI Kimi,Polygon Visualization,Overlap Filter,Anthropic Claude,Dimension Collapse,Roboflow Dataset Upload,Morphological Transformation,Detection Event Log,Bounding Box Visualization,SmolVLM2,Template Matching,VLM As Classifier,Image Contours,Image Slicer,Stability AI Outpainting,Anthropic Claude,Environment Secrets Store,Roboflow Custom Metadata,Multi-Label Classification Model,SAM2 Video Tracker,Barcode Detection,Roboflow Asset Library Attributes,Camera Calibration,Morphological Transformation,Detections Stabilizer,Path Deviation,Relative Static Crop,Mask Area Measurement,Background Color Visualization,Model Monitoring Inference Aggregator,Clip Comparison,Corner Visualization,GeoTag Detection,SIFT,Track Class Lock,Dominant Color,Moondream2,Property Definition,Roboflow Visual Search,OpenRouter,Identify Changes,Bounding Rectangle,Overlap Analysis,Llama 3.2 Vision,Qwen3.5-VL,CLIP Embedding Model,Email Notification,Single-Label Classification Model,Triangle Visualization,OpenAI,Pixel Color Count,Roboflow Dataset Upload,OC-SORT Tracker,Image Preprocessing,First Non Empty Or Default,SIFT Comparison,YOLO-World Model,Halo Visualization,Label Visualization - outputs:
Keypoint Visualization,Twilio SMS/MMS Notification,OPC UA Writer Sink,Keypoint Detection Model,Perception Encoder Embedding Model,Qwen 3.6 API,SIFT Comparison,Object Detection Model,SAM 3,Grid Visualization,Llama 3.2 Vision,PLC Writer,JSON Parser,Absolute Static Crop,Distance Measurement,Roboflow Visual Search Classifier,Velocity,Image Threshold,Polygon Zone Visualization,CogVLM,BoT-SORT Tracker,MQTT Writer,Contrast Equalization,Google Gemini,Detections List Roll-Up,GLM-OCR,OCR Model,Background Subtraction,Contrast Enhancement,Reference Path Visualization,Google Gemma API,Instance Segmentation Model,Mask Edge Snap,Twilio SMS Notification,PTZ Tracking (ONVIF),Detections Classes Replacement,Detections Merge,Detections Filter,VLM As Detector,Florence-2 Model,Halo Visualization,SAM 3 Interactive,Dynamic Crop,LMM,Image Blur,Seg Preview,SAM 3,Ellipse Visualization,OpenAI,Florence-2 Model,Byte Tracker,Line Counter,LMM For Classification,Time in Zone,Path Deviation,Instance Segmentation Model,OpenAI,Event Writer,Semantic Segmentation Model,Cache Set,Data Aggregator,Time in Zone,Single-Label Classification Model,Keypoint Detection Model,Google Gemma,Byte Tracker,Buffer,Slack Notification,Heatmap Visualization,Semantic Segmentation Model,SORT Tracker,Email Notification,Circle Visualization,Perspective Correction,Camera Focus,Byte Tracker,Keypoint Detection Model,Detections Consensus,Crop Visualization,Polygon Visualization,Line Counter,ByteTrack Tracker,Multi-Label Classification Model,Detections Combine,Stability AI Inpainting,OpenAI-Compatible LLM,SAM 3,Object Detection Model,VLM As Classifier,PLC ModbusTCP,Google Gemini,Image Slicer,Roboflow Vision Events,Detections Transformation,Multi-Label Classification Model,Size Measurement,Qwen3.5,Local File Sink,Delta Filter,Object Detection Model,Inner Workflow,SAM3 Video Tracker,Dot Visualization,QR Code Detection,Line Counter Visualization,Time in Zone,Instance Segmentation Model,Depth Estimation,Expression,Stitch OCR Detections,PP-OCR,Clip Comparison,Blur Visualization,EasyOCR,Anthropic Claude,PLC EthernetIP,Segment Anything 2 Model,CSV Formatter,Color Visualization,Per-Class Confidence Filter,Qwen3-VL,Qwen2.5-VL,Dynamic Zone,Image Convert Grayscale,Motion Detection,Stitch OCR Detections,Rate Limiter,Single-Label Classification Model,Qwen 3.5 API,Trace Visualization,Icon Visualization,Current Time,Cache Get,PLC Reader,Model Comparison Visualization,Camera Focus,QR Code Generator,Google Gemini,Detections Stitch,Image Stack,Instance Segmentation Model,Qwen-VL,Mask Visualization,MoonshotAI Kimi,Microsoft SQL Server Sink,Text Display,Gaze Detection,Stability AI Image Generation,Continue If,Google Vision OCR,Webhook Sink,OpenAI,VLM As Detector,Identify Outliers,Cosine Similarity,Pixelate Visualization,Stitch Images,Detection Offset,S3 Sink,Classification Label Visualization,Switch Case,MoonshotAI Kimi,Polygon Visualization,Overlap Filter,Anthropic Claude,Dimension Collapse,Roboflow Dataset Upload,Morphological Transformation,Detection Event Log,Bounding Box Visualization,SmolVLM2,Template Matching,VLM As Classifier,Image Contours,Image Slicer,Stability AI Outpainting,Anthropic Claude,Roboflow Custom Metadata,Multi-Label Classification Model,SAM2 Video Tracker,Barcode Detection,Camera Calibration,Roboflow Asset Library Attributes,Morphological Transformation,Detections Stabilizer,Path Deviation,Relative Static Crop,Mask Area Measurement,Background Color Visualization,Model Monitoring Inference Aggregator,Clip Comparison,Corner Visualization,GeoTag Detection,SIFT,Track Class Lock,Dominant Color,Moondream2,Property Definition,Roboflow Visual Search,OpenRouter,Identify Changes,Qwen3.5-VL,Overlap Analysis,Llama 3.2 Vision,Bounding Rectangle,Email Notification,Single-Label Classification Model,CLIP Embedding Model,Triangle Visualization,OpenAI,Roboflow Dataset Upload,Pixel Color Count,OC-SORT Tracker,Image Preprocessing,First Non Empty Or Default,SIFT Comparison,YOLO-World Model,Halo Visualization,Label Visualization
Input and Output Bindings¶
The available connections depend on its binding kinds. Check what binding kinds
First Non Empty Or Default in version v1 has.
Bindings
-
input
data(*): List of data references (selectors) to check for non-empty values, in priority order. Each selector can reference outputs from different workflow steps or execution branches. The block iterates through this list and returns the first non-empty (non-None) value encountered. If all values in the list are empty/None, the default value is returned. Minimum 1 item required. Order matters: earlier items in the list have higher priority. Common use cases: merging outputs from conditional execution branches, providing fallback data sources, or combining results from alternative processing paths..
-
output
output(*): Equivalent of any element.
Example JSON definition of step First Non Empty Or Default in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/first_non_empty_or_default@v1",
"data": [
"$steps.my_step.predictions"
],
"default": "empty"
}