I’ve been testing an intake workflow with validation and a deliberately triggered hard failure.
The next case I want to add is different:
Valid input enters the workflow.
An upstream call returns successfully but produces no usable items.
No database record is written.
The execution remains green.
My proposed check is to record accepted, processed, and written counts, then assign an explicit result:
completed;
legitimately empty;
incomplete.
A simple count mismatch alone won’t be enough because zero output may be expected for some inputs. The workflow needs to know which outcome was intended.
I haven’t verified this test yet. I’m sharing the planned failure case before presenting the demonstration as broader reliability coverage.
If you’ve tested this pattern in n8n, what evidence did you use to distinguish an expected empty run from silent data loss?
Hey @Ayub_Shah! Distinguishing expected empty runs from silent data loss is a key challenge for robust n8n workflows!
Your plan to track accepted, processed, and written counts, then assign explicit states (e.g., legitimately empty, incomplete) is an excellent approach.
How I would implement this in n8n:
Input Context: Can the initial input carry a flag indicating if zero output is expected?
Set Nodes: Store counts and the expected outcome state throughout.
Function Node: Compare actual item counts against expected values. If 0 items resulted but 0 was expected, flag it ‘legitimately empty’. For an unexpected zero, use a conditional Stop and Error or send a dedicated notification via HTTP Request to your logging.
This internal awareness helps make these distinctions. Happy building!
One thing that has worked for me is to stop relying only on item counts and to ask the upstream system for its own number. Many APIs return a total or a next-page marker alongside the items. If the response says there are 12 matching records and your node outputs 0, that is silent loss. If it says 0 and you output 0, that is a legitimate empty run. Storing that upstream count next to your accepted, processed and written counts gives you the evidence you are asking about.
For the empty branch, a few more checks are cheap. Look at the HTTP status and any error field in the body, because some APIs return 200 with an empty list when a filter or credential is wrong. Check that the nodes that can return nothing have the right “always output data” setting, so the workflow does not stop quietly. Finally, keep two test fixtures, one input that should produce records and one that should produce none, and assert the expected result label for each on every change.
For production, a scheduled check that alerts when a normally busy workflow has written nothing for longer than usual catches the cases your tests did not think of.
Comparing against the upstream system’s own total is stronger than relying only on internal workflow counts. It gives the workflow an external expectation rather than asking it to judge itself.
I also like the two-fixture idea: one case that must produce a record and one that should legitimately produce none. That should help prevent expected empty runs from triggering false alarms.
For the first version, I’m thinking of recording:
upstream expected count
accepted count
processed count
written count
final outcome and reason
Then I can test a known 1 expected → 0 written failure separately from a genuine 0 expected → 0 written result.
The “normally busy but suddenly empty” check feels like a second layer for production monitoring rather than the main per-run decision. Thanks, this gives the test a much clearer evidence model.
Thanks. Carrying the expected outcome with the input makes sense when the caller already knows whether an empty result is valid.
I think I’ll keep that expectation separate from the observed result, so the workflow can compare:
what should have happened;
what actually happened;
why an item was skipped or produced no output.
One limitation is that the input won’t always know the expected count. In those cases, I’d need evidence from the upstream response or a later reconciliation check rather than automatically treating zero as valid.
One thing that helped me was writing down the outcome you expected before the run, not after: if the trigger says “new lead”, zero writes is incomplete, not empty. Are you planning to alert on “incomplete” right away, or count them up over a day first?
Silent green executions are far more dangerous than hard errors because monitoring dashboards assume everything succeeded normally.
Adding a validation assertion at the end of the pipeline that compares incoming item counts against committed database records ensures zero-record runs fail loudly.
The tricky case is when zero is actually correct, like a trigger with nothing new. Do you compare against the input count only, or against something upstream too?
I’d compare against the strongest expectation available, not the input count alone.
If the trigger represents one accepted lead, then 1 accepted → 0 written is incomplete. For a search or polling workflow, I’d use the upstream total or response metadata because zero may be completely valid.
My current thinking is:
expected count or outcome from the trigger/upstream system
accepted count
written count
reason for any intentional skip
For alerting, I’d flag event-driven cases like a missing lead immediately. For scheduled polling, I’d first mark the run as legitimately empty, then use a separate time-based check if the workflow stays empty longer than normal.
Agreed that an end-of-run assertion is useful, but I don’t want every zero-record run to fail automatically.
The assertion needs an expectation to compare against. If the upstream system reports zero matching records, then zero writes may be correct. If it reports records, or the trigger represents an accepted item, then zero writes should become incomplete and alert.
I’m going to test both cases side by side so the workflow can fail loudly on silent loss without turning legitimate empty runs into false alarms.
There is an execution-path trap in the end-of-run assertion: with body-only JSON output, an HTTP Request response of [] emits zero items, so the downstream assertion gets skipped.
I ran your three fixtures on n8n 2.41.7, using a local HTTP-200 source and a separate mock commit ledger:
Fixture
Original saved execution
End check
Fixed result
1 expected, 1 written
success
ran
completed
0 expected, 0 written
success
skipped
legitimately_empty
1 expected, 0 written
success
skipped
incomplete + error
The small fix is to enable Include Response Headers and Status on the source HTTP Request. That keeps one envelope with body: []. Check whether empty was expected before splitting that body into items: expected zero gets an explicit empty outcome; expected one reaches Stop and Error. The normal branch checks the mock write receipt.
The sample covers zero/one record. For batch writes, reconcile committed record IDs from the database’s RETURNING or read-back against the expected IDs.
Does your source return a bare array or an object wrapping the rows? That determines where to preserve the envelope in your intake.
blucca’s #12 is the scary part to me: if an empty body skips the end check, the ‘stays empty too long’ check probably has to live outside the workflow. How are you thinking of setting ‘longer than normal’ for the polling ones, a fixed window per workflow or something based on its history?