A single line of Python made my validator silently stop checking after the first failure

by•

Wrote a script to validate blog drafts before publish. The check was all(validate(p) for p in sys.argv[1:]). Ran it against a 125 file backlog and got back exactly one line of output.

all() on a generator expression stops at the first False. Every file after the first failure never even ran through the checks, let alone printed anything. It looked like a clean pass because there was one failure and then silence, not because 124 files were fine.

Fixed by evaluating eagerly with a list comprehension first, so every item actually runs and prints.

What is a check you trusted was exhaustive that turned out to have quietly stopped after the first hit?

8 views

Add a comment

Replies

Best

I’ve hit this with `Promise.all()` in JavaScript. I assumed every task would finish cleanly, but one rejection ended the aggregate result while other operations were still running. Now I use `Promise.allSettled()` when every result needs to be inspected.