AI Folks
  • Courses
  • Web Of AI
  • Pricing
  • Enterprise
Log in
PreviousCalling any APINextWhat an agent is

Vibe Coder · Unit 15: Workflows With n8n · Lesson 6 of 6

When workflows fail

Workflows fail quietly unless you make them loud. Read failed executions, add retries, build an error workflow that alerts you, and publish your workflows to GitHub.

Read the short notes and pictures.Do everything inside a blue frame.

Automation fails in the dark

When a screen breaks, a user tells you. When a workflow breaks at three in the morning, nobody does. The signup simply never gets its email. The work of this lesson is making sure you find out, and that a failure does as little harm as possible.

Reading a failed execution

  1. 1

    Open the executions list

    Filter for errors.

  2. 2

    Open the failed run

    The failing node is marked. Everything before it shows the data that flowed through.

  3. 3

    Read the error message

    And the input to the failing node. Most failures are a missing field, an expired key or a service that was down.

  4. 4

    Fix and re-run

    You can run the workflow again from the editor with the same data.

Retries

A node that calls another service can fail for reasons that pass on their own: the service was busy, the network dropped. Node settings let you retry on failure, a set number of times with a pause between tries. Turn that on for nodes that call outside services. Do not use it to hide a real bug.

An error workflow

A concrete wall, hand-drawn. Three nodes: Error Trigger, build a message, send it to me.
An error workflow starts with an Error Trigger and tells you what failed.

n8n lets you nominate one workflow to run whenever another fails. It starts with an Error Trigger node, which receives the name of the failed workflow, the node and the error. From there, send yourself a message. Set it as the error workflow in the settings of every workflow you publish.

Safe to run twice

Retries, re-runs and duplicate events all mean a step may happen twice. For a notification that is a small annoyance. For a charge or an email to a customer it is a real problem. The fix is to make each risky step check before it acts.

A concrete wall, hand-drawn. Two cards: steps that are not safe to repeat, and versions that check first.
A step that checks before it acts is safe to repeat.

Use the event’s id

Payment providers send an id with every event. Save it, and skip any event whose id you have already handled.

Update, do not insert

Write to the row with this id rather than always adding a new row.

Record what you sent

A "welcome_sent" column lets the email step skip people who already have it.

Humans in the loop

For anything that cannot be undone, such as a refund or a deletion, have the workflow ask for your approval instead of acting. A message with an approve link and a Wait node is enough.

Publish your workflows to GitHub

A workflow is part of your product, so it belongs in your repository with the rest. n8n exports any workflow as a JSON file. Credentials are not included in the export, which is what you want.

  1. 1

    Export each workflow

    From the workflow menu, download it as JSON.

  2. 2

    Add them to your repository

    In a folder such as workflows/, one file per workflow, named for what it does.

  3. 3

    Write a short README

    For each workflow: what triggers it, what it does, which credentials it needs, and its webhook request and response shapes.

  4. 4

    Commit and push

    With a message that says what changed.

  5. 5

    Repeat after every change

    So the file in GitHub always matches what is running.

Check the file before you push

Open the exported JSON and search for anything that looks like a key or a token. If you ever typed a secret directly into a node, it will be in the file. Move it to a credential, re-export, and rotate the key.

ActivityYour turnWrite it yourself first, then compare.

Your payment workflow received the same "payment succeeded" event twice and upgraded nobody twice, but it sent two receipts. What one change prevents this?

ActivityBuild stepYour product’s back office

Harden and publish your workflows

Add an error workflow that messages you, switch on retries for nodes that call outside services, and make your riskiest step safe to run twice. Then export every workflow and push them to your product’s GitHub repository with a README.

Done when

This folder is your back office, in version control. Keep it up to date for the rest of the course.

Keep these

  • Failed executions show the node, the data and the error.
  • Retry what passes on its own; alert yourself for the rest.
  • Make risky steps safe to repeat, and keep workflows in GitHub.
Previous lessonCalling any APIProject · milestone 15Your product’s back office