ai-automation-consultant / Failure Lab
n8n Empty Items Expression
A Code node assumes the first item exists and crashes on an empty filtered result.
Category
n8n
Difficulty
intro
Last Run
none
Incident Brief
Diagnose the n8n expression failure and propose a safe fallback.
Broken State
A previous filter can return zero items, but the Code node reads items[0].json.email unconditionally.
Symptoms
- The workflow succeeds for normal leads and crashes for spam-filtered submissions.
- No review task is created for the empty result.
Trace
TypeError: Cannot read properties of undefined (reading 'json') filtered_items=0 node=normalize_contact