Skip to content

Lesson 17 ยท Errors and Debugging

Debugging and Reliable Workflows

Find bugs with n8n execution history, debug in editor and pinned data, make workflows idempotent against duplicates, and test edge cases before you publish.

When something goes wrong, you need two skills: finding the cause quickly, and building so that the same problem cannot do damage again. This lesson covers both, using n8n's execution history and a few engineering habits.

Read the executions

Every run is an execution. In the executions list you can filter by status, open a failed run and click through the nodes to see exactly what each one received and produced. Production webhook and form data appears here, not in the editor.

A debugging routine:

  1. Find the first node that behaves unexpectedly, not just the last one that failed.
  2. Compare its input with what you assumed.
  3. Check item counts. Zero items, or 1,000 instead of 1, explains many bugs.
  4. Read the full error message, including details.
  5. Change one thing, then test again.

Debug past data

For a failed execution, Debug in editor copies its data into your current workflow and pins it to the first node. For successful runs there is a similar Copy to editor action. You can then reproduce the problem without waiting for the real event. You can also retry an execution while n8n still stores it.

Keep in mind that old executions are pruned. On self-hosted instances, the default settings remove data older than 14 days (336 hours) or beyond 10,000 executions, whichever applies, and you can change them with environment variables. If you cannot find an old run, it may have been deleted. Pinned data can contain private information, so remove it when you finish.

Trial runs without damage

  • Use test credentials and a test destination.
  • Add a Limit node so a test touches only a few items.
  • Disable the final "send" or "delete" node while checking earlier steps.
  • Add a dry run flag that logs actions instead of performing them.

Idempotency: safe to run twice

A workflow is idempotent if running it again with the same input has no extra effect. Duplicates happen: senders retry, you replay failed runs and schedules overlap. Ways to protect yourself:

  • Use a unique ID from the source, such as an order ID.
  • Check whether the destination already holds that ID before creating it.
  • Use upsert (insert or update) where available, ideally backed by a unique constraint in the database.
  • Send an idempotency key to APIs that support it.
  • Record processed IDs, for example with Remove Duplicates or a table.
Python Stand-in: process each event once

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

This simple version records the ID before doing the work. If the work then fails, you need a way to retry it, for example by storing a status such as started or done. Think about which failure is worse for your case: doing something twice or not at all.

Test edge cases

Before publishing, send your workflow:

  • no items at all;
  • one item and many items;
  • missing fields, empty text and null;
  • special characters, long text and other languages;
  • a service that returns an error or times out.
JS Stand-in: a tiny test table for a transform

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Make problems visible

Add useful names and notes, record key counts (items read, written and skipped), and connect an error workflow. Also watch for silent failure: a trigger that stopped firing produces no errors. A daily "heartbeat" message or a check that expected data arrived helps you notice.

Common mistakes

  • Editing production directly and publishing without a test run.
  • Replaying failed runs that already sent some messages.
  • Assuming no alerts means everything works.

Keep notes on incidents

When you fix a real problem, write down a few lines: the symptom, the cause, the fix and the test you added. Over time this becomes a list of risks specific to your systems, such as an API that returns an empty list during maintenance, or a source that sends dates in two formats. Add a matching case to your sample data so the next change does not bring the bug back. Review old workflows now and then, since services change.

Practice

Take any workflow you have built in this course and break it on purpose in a test copy: rename a field in the source, send an empty list, use a wrong key and deliver the same event twice. For each experiment, write what you expected, what happened and how you would have noticed in real life. Then fix the weakest point first. You will usually find at least one case where the workflow reports success even though it did nothing useful. Add a count check or an explicit error for that case, and run all four experiments again to confirm the improvement.

Check your understanding

Quick check ยท 3 questions

of 3 answered You scored / 3 ยท perfect!

  1. 1. What does idempotent mean for a workflow?

    Safe repetition protects you from duplicates.
  2. 2. What does Debug in editor do for a failed run?

    It lets you reproduce the problem with real input.
  3. 3. Why might an old execution be missing?

    Retention settings delete old execution data.

Summary

  • Start debugging at the first unexpected node and check item counts.
  • Debug with past execution data, but remember pruning and privacy.
  • Design for duplicates with unique IDs and constraints.
  • Test edge cases and watch for silent failures.

Next: The AI Agent Node

Your progress is saved in this browser. No account needed.