Tips > Reliability & Performance

Test Error Paths Deliberately by Breaking Credentials

Your error handling is only as good as its last test.

TipAdvanced2 min read

Your error handling is only as good as its last test. Periodically verify that your error workflows, retry logic, and alerting actually work by deliberately introducing failures. The simplest method: temporarily modify a credential to use an invalid value, run the workflow, and verify the error chain fires correctly.

Real-world example: You built an error workflow six months ago. Since then, someone renamed the Slack channel it posts to. Your error handling has been silently broken for months. Deliberate testing would have caught this.

Error Path Testing Checklist:

1. Test the Error Workflow trigger:
   - Temporarily change an API credential password to "test_invalid_password"
   - Activate the workflow and trigger it
   - Verify: Does the error workflow fire?
   - Verify: Does the Slack/email notification arrive?
   - Verify: Does the error message contain useful information?
   - Restore the credential immediately after testing

2. Test retry behavior:
   - Set a node's URL to a known-failing endpoint (e.g., httpstat.us/500)
   - Run the workflow and observe:
     - Does it retry the configured number of times?
     - Do the wait intervals match your configuration?
     - Does the final failure trigger the error workflow?

3. Test Continue on Fail:
   - Feed a batch with one deliberately bad item
   - Verify: Does the workflow process the good items?
   - Verify: Is the bad item routed to the failure branch?
   - Verify: Does the DLQ entry contain enough info to diagnose?

4. Test the circuit breaker:
   - Manually set the failure counter to threshold - 1
   - Trigger one more failure
   - Verify: Does the circuit open?
   - Verify: Does the alert fire?
   - Verify: Do subsequent executions skip the API call?
```text
A Code node for testing with a controlled failure:

```javascript
// Code node: "Controlled Failure for Testing"
// Toggle the shouldFail flag to test error paths

const shouldFail = true; // Set to true for testing, false for production

if (shouldFail) {
  throw new Error(
    'DELIBERATE TEST FAILURE: Testing error handling pipeline. ' +
    'If you see this in production, someone left the test flag on.'
  );
}

return $input.all();
```text
> **Tip: Schedule quarterly error path testing**
>
> Create a calendar reminder to test error paths quarterly. Treat it like a fire drill. The 15 minutes spent testing saves hours of debugging when a real failure happens and your alerts are broken.

Error handling that has never been tested is error handling that does not work. Test it deliberately and regularly.

**Related:** [Use "Pin Data" to Freeze Node Output](../testing-and-debugging/01-use-pin-data-to-freeze-node-output.md) | [Break Large Workflows into Sub-Workflows](../workflow-architecture/01-break-large-workflows-into-sub-workflows.md)

Want this running in your stack?

I build production n8n and Cloudflare automation for teams — the same engineering behind HarperFlow. Fixed-price, escrow-protected, US-based.