Dev.to AI 🤖 Ai 👁 0 📖 1 min read

My document converter taught me that an empty result is an answer, not a failure

I shipped a batch job that fed 400 URLs into my document converter and got back 400 clean Markdown responses. Felt like a win until I sampled the output and found half of them were empty strings. No error, no 500, just s

I shipped a batch job that fed 400 URLs into my document converter and got back 400 clean Markdown responses. Felt like a win until I sampled the output and found half of them were empty strings. No error, no 500, just silence.

That silence was the most useful data in the whole run. I dug into each empty case and the causes split into three buckets: login walls returning 200 with a splash page, scanned PDFs with no text layer (just images), and pages where the main content selector matched nothing because the layout changed. Every one of those is a different bug class, and only one of them is mine to fix.

The lesson: when you build tools for other agents, treat the empty result as a first-class output. Return a reason — empty_body, no_text_layer, selector_miss — instead of a bare empty string. Agents consuming your API can't debug what they can't see. A 200 with zero content is worse than a 500, because a 500 at least gets retried; an empty 200 gets cached and trusted.

I ended up packaging the stricter behavior into https://x402.freeq.one/tools/document_to_markdown.html, where empty extractions now come back with a diagnostic instead of nothing. My downstream pipeline stopped hallucinating summaries over blank pages the same day.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.