n8n dedupe trap: alwaysOutputData + error output runs both branches

To deduplicate leads in n8n you typically look the email up in Google Sheets first. If there is no match the Sheets node returns no items and the workflow silently stops, so people turn on Always Output Data: now "not found" produces one empty item you can route to "add new lead". I combined that with On Error: continue (using error output) to send an "ACTION NEEDED" email when the sheet is unreachable. Testing with a broken tab name showed a nasty interaction. What happened With the lookup failing, both of these ran: the error output → ACTION NEEDED email (correct), and the main output, because Always Output Data added an empty item → treated as "new lead" → appended to the sheet → auto-reply → 200 OK to the form. So the owner got an alarm and a "new lead" email, and the form was told everything was fine. With an expired credential instead of a typo, the append would fail too and you would get two alarms for one lead. The fix Use On Error: Continue (regula

n8n dedupe trap: alwaysOutputData + error output runs both branches

To deduplicate leads in n8n you typically look the email up in Google Sheets first. If there is no match the Sheets node returns no items and the workflow silently stops, so people turn on Always Output Data: now "not found" produces one empty item you can route to "add new lead".

I combined that with On Error: continue (using error output) to send an "ACTION NEEDED" email when the sheet is unreachable. Testing with a broken tab name showed a nasty interaction.

What happened

With the lookup failing, both of these ran:

  • the error output → ACTION NEEDED email (correct), and
  • the main output, because Always Output Data added an empty item → treated as "new lead" → appended to the sheet → auto-reply → 200 OK to the form.

So the owner got an alarm and a "new lead" email, and the form was told everything was fine. With an expired credential instead of a typo, the append would fail too and you would get two alarms for one lead.

The fix

Use On Error: Continue (regular output) on the lookup node instead of the error output, and route all three cases with a Switch:

Case What the item looks like Route
Lookup failed has error ACTION NEEDED email, reply 202
Match found has row_number update existing row
No match empty item from Always Output Data add new lead

Each case now has exactly one path. I tested all three against a real sheet, plus a form post with the email in different upper/lower case to confirm the dedupe matches.

Disclosure: this comes from building my Lead Capture for n8n kit. The pattern above is all you need to fix it in your own workflow.

Share