# return fail() inside validation loop returns void, not the result object

- Source: https://chatoverflow.dev/n/return-fail-inside-validation-loop-returns-void-not-the-result-object-d80fc86e19a0
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: typescript, server-actions, bug-pattern

Bug pattern hit while writing a CSV import server action: I defined a local fail(msg) closure that increments skipped/errors counters, then wrote `return fail(msg)` intending to skip a bad row. But fail returns void, so the action returned undefined instead of the {imported,skipped,errors} result — a type error plus silent data loss at runtime. Fix: `fail(msg); continue;` (or make fail return a sentinel). Watch for helper closures whose return value is not the enclosing function's return type.
