I run my quotes and invoices through a small admin dashboard that hands the real work to n8n. Each button posts to a webhook, and a workflow does the rest: fetch the record, build or fetch the PDF, email it, stamp the database, post to Telegram, respond.
One of those buttons, “Resend invoice”, had been live for two days before I noticed there was no workflow behind it at all. It posted into the void. Nobody had pressed it in anger yet, which is the only reason this is a blog post and not an apology to a client.
Writing the workflow took an hour. What made it worth writing up is everything that happened after the workflow looked finished.
“Built” is not “works”
The first version passed every check I could run without touching anything real. The JSON parsed. Every node connected to something and every path could be reached. There were no secrets in the export. I pulled the JavaScript out of the Code node and ran it under Node against fixtures covering every validation branch and every invoice status, and it behaved.
That proves the workflow is internally coherent. It proves nothing about whether it works against a real Postgres database, a real Gmail account, a real PDF store and a real Telegram bot. I wrote down that distinction at the time, because it is very easy to tick a box on the strength of the first kind of evidence and discover you needed the second.
So it got imported and run for real. Two bugs appeared within minutes, and neither could have been caught by anything I had already done.
Bug one: a malformed id returned a silent, empty 200
The workflow’s first real step queries the database for the invoice. The Code node that validates the incoming id sat after that query, on the reasoning that it could validate the invoice and the id together.
Then I sent it an id that was not a valid UUID. Postgres, asked to compare a non-UUID string against a UUID column, threw a cast error. The run halted at the query node. And the webhook, which had not reached its Respond node, returned a bare 200 with an empty body.
To the dashboard, an empty 200 is success. So a malformed request would have shown the user a green tick for an email that was never sent.
The fix was one line, comparing on id::text so a bad id simply matches nothing and falls through to the “invoice not found” branch. But the lesson is bigger than the fix:
- Validate before you query, not after. Anything that can throw on bad input should be behind the check, not in front of it.
- Know what your webhook returns when a run dies. If the answer is “200, empty”, then every caller has to treat an empty body as failure, or the workflow has to guarantee it always reaches a Respond node.
The fixture tests could never have found this. They never touched Postgres, and Postgres was the thing that threw.
Bug two: a notification killed a successful run
The workflow’s last few nodes were, in order: log the resend in the database, notify Telegram, respond to the webhook.
On the first real run, the email went out, the database was stamped, and then the Telegram node failed on a dead credential. Because it sat between the log and the response, the whole run failed after the email had already been sent. The dashboard got an error for an action that had in fact succeeded.
That is the worst kind of wrong: a user who sees an error presses the button again, and the client gets the invoice twice.
The fix was to set the Telegram node’s error handling to continue (onError: continueRegularOutput), so a failed notification is just a failed notification. The general rule is worth more than the fix, though. A side effect that is not the point of the workflow should never be able to fail the workflow. Notifications, analytics, logging to a second place: all of it either goes after the response, or is set to continue on error.
The bigger problem it uncovered
Why was the Telegram credential dead?
It turned out every Telegram node in the instance used the same credential. That included all five live workflows, and it included the error handler: the workflow whose whole job is to tell me when another workflow fails. The token had stopped working at some point, and from that moment, every failure alert I relied on had been going nowhere.
Nothing had told me, because the thing that tells me was the thing that was broken. I only found out because a brand-new workflow happened to put a Telegram node somewhere its failure was visible.
The token was replaced the same day. Two other workflows still had the same “notify before respond” shape and went on the fix list. And I changed how I think about alerting: an alerting path that has not fired recently is not evidence that nothing is wrong. It might be evidence that the alerting is. Something has to test the alarm, not just the things the alarm watches.
The order I tested in, and why it mattered
One decision made all of this safe to find. Before anything could email a real client, I ran the cheap failure cases first: an unknown id, a missing id, a malformed id, a cancelled invoice, an invoice with no PDF. None of those send anything. All of them exercise the database connection, the credential bindings and the routing.
It was the very first of those, the bogus id, that exposed bug one. If I had started with a happy-path test on a real invoice, the first thing to break would have been in front of a client.
So the rule I now follow for any workflow that sends something to a person: prove the plumbing on requests that cannot send, then send.
What I would take from it
- Static checks prove a workflow is coherent. Only a live run proves it works. Record which one you have actually done.
- Validate input before anything that can throw on it.
- Decide what your webhook returns when a run dies, and make sure every caller agrees.
- Side effects go last, or continue on error. Never between the work and the response.
- Test your alerting, not just what it watches.
- Run the requests that cannot send before the ones that can.
None of this is exotic. It is the unglamorous part of automation, which is most of it, and it is the part that decides whether the thing can be trusted when nobody is watching it.