The empty dataset that lied: teaching an Apify Actor to tell "no data" from "blocked"

My Reddit Actor passed its release gate at 100% success, with 13 empty datasets. Twelve of them were silent data loss. This is how I made that impossible.
👉
This article was written by Oleg Naryzhnykh as part of Write for Apify - a program for developers sharing original articles about what they've built with Apify.

On August 8 I was one checklist item away from publishing my fourth Apify Actor, a pay-per-event Reddit scraper. The last item is a release gate I run before anything goes live: 50 platform runs across a fixed set of scenarios, with a bar of at least 95% success. The gate came back 100% SUCCEEDED.

It covers every scenario type the Actor supports: subreddit listings in four sort orders, post comment trees, search, and user profiles. All 58 internal tasks succeeded, 1,354 items came back, the median run took 5.3 seconds, and request pacing stayed well inside my self-imposed limit of 10 requests per minute per address. On paper, a perfect gate. It also came back with 13 of the 50 runs holding an empty dataset.

An empty dataset is not a failure by itself. A throwaway account with no post history, a search phrase nobody ever wrote, or a subreddit where the date filter excludes everything will all legitimately produce zero rows. So I did the one thing that separates "fine" from "not fine" and replayed every empty scenario twice, 29 requests in all, since some scenarios paginate. Ten of the thirteen came back full on both replays. The subreddit listing that had returned nothing now produced its ten posts, twice in a row. A search query went from zero to eight items on each replay, and a comment tree from zero to ten and ten.

I never got to inspect one of the offending pages directly. The runs went through the platform's proxy, my plan doesn't allow using that proxy from outside a run, and run logs don't store response bodies. The diagnosis therefore rests on reproducibility: thirteen scenarios, each replayed twice, ten of them flipping from empty to full with no change of input. Whether the page was a soft block, a cold cache, or some regional interstitial, I can't say. What I can say is that it was not the data.

The data had been there the whole time. On those runs the site answered HTTP 200 with a complete HTML document, closing </html> tag in place, that contained not a single post node, and my Actor recorded "success, zero items" and moved on. Each of those runs told the buyer a small lie: a green checkmark, an empty file, and no explanation.

This article is about what it took to make that lie impossible: the page forensics, the classification taxonomy that fell out of them, and the second and stranger non-data state I found while fixing the first. The fix nearly doubled the data returned from an identical set of runs, from 1,354 items to 2,545. None of that data was new. All of it had been silently dropped.

Why a machine caller makes it worse

I care about this failure mode more than most, because I've spent the past weeks watching how AI agents call Actors. Through Apify's Model Context Protocol (MCP) server, an agent searches Apify Store, reads an Actor's card, calls it with a JSON input, and gets back a run status and a dataset. I've traced that pipeline call by call, and one property of it stands out here: the agent believes the status.

A human buyer who gets an empty CSV squints at it, mutters, and clicks Run again. An agent that gets SUCCEEDED with zero items has received, as far as it can tell, a definitive answer. It will report to its user, in fluent and confident prose, that the subreddit is quiet, that nobody discusses this topic, that the account has no history. The wrongness doesn't stop at the empty file; it compounds into whatever the agent does next.

And there is nobody downstream who can catch it. The platform sees a run that exited cleanly, and the caller sees a valid, well-formed, empty result. The only party that ever held the bytes of the page, and so the only one that could have noticed the page was wrong, is the Actor. That makes the Actor the place where "no data" and "we got nothing, but it wasn't data" have to be told apart. On an Actor that agents call, that distinction belongs in the same category as parsing the data correctly, not in a list of reliability nice-to-haves.

The billing side makes it slightly worse. My Reddit Actor charges per event, per post and per comment, with no start fee, so a silently empty run doesn't cost the buyer anything at all. That sounds harmless until you follow the consequence: nothing about the run shows up on an invoice, so nothing prompts anyone to go back and look at it.

Apify Console showing a Reddit Data Scraper run with status Succeeded and zero results
One of the thirteen, as Apify Console shows it: "Success! Everything went according to plan" and no results. The $0.001 is my own platform usage; a pay-per-event buyer is billed per item, and zero items bill zero events.

Retrying every zero is the wrong fix

The embarrassing part is that I had already built a guard against bad pages. An earlier round of testing had caught flaky proxies delivering truncated bodies, so the parser rejected any response without a closing </html> tag and retried the task. That guard worked perfectly and caught nothing here, because these pages were whole. Each guard catches exactly the failure you named when you wrote it, and I had named "incomplete page", not "complete page with nothing inside".

The reflexive next fix is one line: treat zero items as a failure and retry everything. I priced that out and threw it away.

My retry budget is three attempts on top of the first. A genuinely empty page, the throwaway profile with no history, fails that policy every time, because no amount of retrying makes an empty profile less empty. Under retry-everything, each honestly empty source costs four requests instead of one, takes four pacing delays instead of one, and then fails the task anyway. A buyer who asked a legitimately empty question would wait longer and, on an Actor that charges per item, get a FAILED run for a correct answer. That turns the most honest result the Actor can produce into its worst user experience.

What I needed instead was a witness: something on the page itself to testify that the emptiness was real.

Reddit signs its emptiness

It turns out old.reddit.com signs its empty pages. On a listing or a profile with nothing to show, the page contains a marker element right where the content would have been:

<p id="noresults" class="error">there doesn't seem to be anything here</p>

On search pages the wording is the same but the structure differs: Reddit marks the empty result group with an info element in its footer (.search-result-group footer .info). I confirmed both forms with live requests, then checked the seven populated fixture pages my test suite is built on, and neither form appears on any of them. That gave me no false positives in either direction: a page with data never carries the marker, and a genuinely empty page always does.

An old.reddit.com user profile showing the red text "there doesn't seem to be anything here" where posts would be
The witness: Reddit's own "there doesn't seem to be anything here", rendered exactly where posts would be.

That marker turns the fuzzy question "did we get blocked?" into a decidable one. Every response now lands in exactly one of three buckets:

  1. The page contains at least one candidate node for its page type. That is data, so parse it and ship it.
  2. The page has zero candidate nodes but carries the marker. That is declared emptiness: a success with zero items and no retry, so an honest empty still costs exactly one request.
  3. The page has zero candidate nodes and no marker. That page is an impostor, and the task retries with backoff from a fresh proxy session, exactly as it would on any flaky-network error.

Two implementation details carry more weight than their size suggests.

The first is that the count has to be of the page's raw nodes, before any of your own filters touch it. My Actor applies input filters after parsing: an includeNSFW flag, date ranges, and maxItems. A populated page can legitimately filter down to zero rows, and retrying it would be pure waste. The classification has to look at what the page contained, not at what survived my own logic.

The second is the choice of candidate node per page type. For listings the candidate is a post row, and for search it is a result link. Comment pages are the subtle case: the right candidate is the post at the top rather than the comments, because a post always renders on its own page even when nobody has commented, so its absence means a substituted response rather than a quiet thread.

The third state I didn't know existed

While wiring the marker check into tests, I went back to the three scenarios the gate had recorded as honestly empty, three user profiles with apparently no history. Now I had a sharper question to ask of them: does the page carry the marker?

Two of them carried neither the marker nor any posts. Instead, the page title read:

<title>reddit.com: over 18?</title>

That is the age screen old.reddit shows in front of content flagged as adult, arriving as yet another HTTP 200 with a complete HTML document. My classifier had two buckets for a page like this and both were wrong: the page held no data, and it made no claim of emptiness either. The site was asking a question before it would answer one. And the screen doesn't only stand in front of subreddits: an ordinary user profile can be flagged, and then the profile page shows the question where the post history would be. With the age question answered, those two "empty" profiles turned out to hold 3 and 25 posts respectively.

So of my 13 empty runs, 12 had been silent data loss rather than 10: ten impostor pages and two interstitials, all of them filed as success. Of thirteen empty datasets, exactly one had told the truth.

The lesson for the classifier was to stop assuming the taxonomy is complete. I had built a two-state model, data or emptiness, and reality had already shipped a third state. So the third state gets named explicitly: the parser recognizes the interstitial by its title, refuses to file it as a result, and logs exactly what it saw. The general rule underneath it is that a page which is neither data nor a declared empty page must never be recorded as an answer, and that rule covers the states I haven't met yet as well.

What an Actor should do about age-gated content is a separate question, part product decision and part policy, and I am deliberately not turning this article into a how-to on age gates. The short version of my own decision is that the Actor states the same self-attestation an adult visitor gives that screen, and what lands in the buyer's dataset stays governed by an explicit includeNSFW input flag that defaults to off. The transferable part is the detection: know which page you are looking at, and never let a question masquerade as an empty set.

An old.reddit.com age screen reading "You must be 18+ to view this community" with No thank you and Continue buttons
The third state: an HTTP 200, a complete page, zero posts, and no emptiness marker either. (A browser gets redirected to this screen; my Actor received the same interstitial as a 200 at the profile URL itself.) Two of my three "honestly empty" profiles were this.

The classifier that ships

The full classifier, together with the two fixtures the tests further down run on, is in this gist. Here is the same classification as it runs in production today, with framework plumbing trimmed and comments translated (cheerio does the HTML parsing):

import * as cheerio from 'cheerio';
import type { CheerioAPI } from 'cheerio';

// One candidate selector per page type: if a page has zero of these,
// it delivered no data. 'comments' deliberately uses the post node, because
// a post always renders on its own page even with zero comments, so its
// absence means a substituted response rather than a quiet thread.
const CANDIDATE: Record<string, string> = {
  listing: '.thing.link',
  comments: '.thing.link',
  search: '.search-result-link',
  user: '.thing',
};

// Reddit's own signature for "this page is genuinely empty".
function saysNothingHere($: CheerioAPI): boolean {
  return (
    $('#noresults').length > 0 ||
    $('.search-result-group footer .info').length > 0
  );
}

// The age screen instead of content: a third non-data state, named explicitly.
function isAgeScreen($: CheerioAPI): boolean {
  return /over\s*18\?/i.test($('title').first().text());
}

export function assertNotFakeEmpty($: CheerioAPI, kind: string, ref: string): void {
  if ($(CANDIDATE[kind] ?? '.thing').length > 0) return; // bucket 1: data
  if (isAgeScreen($)) {
    throw new Error(`age screen instead of data on ${kind}:${ref} (not an empty result)`);
  }
  if (saysNothingHere($)) return; // bucket 2: declared emptiness, zero items, no retry
  throw new Error(
    `zero items and no empty-page marker on ${kind}:${ref} (impostor page, retrying)`,
  );
}

// parse() loads the response and classifies it up front, before any input filters run:
export function classifyResponse(body: string, kind: string, ref: string): void {
  assertNotFakeEmpty(cheerio.load(body), kind, ref);
}

A thrown classification lands in my pipeline's ordinary retry path, which pauses with backoff, rotates to a fresh proxy session, and tries the task again. That is the identical treatment any transient network error gets, and it is the right treatment for the age screen too: since the Actor has already stated its answer, a screen that still arrives means the answer didn't reach the site, and a retry from a clean session usually delivers it. Declared emptiness returns normally and produces a successful task with zero items.

One adjacent land mine deserves its own paragraph, because it silently undoes this kind of work: your HTTP client probably retries by itself, and you need it not to. My fetcher is built on got-scraping, which, like most HTTP libraries, ships with built-in retries enabled (two, in its case). Those retries fire immediately, from the same address, inside a single fetch() call, skipping both the six-second pacing my README promises and the session rotation my own retry path performs. A retried request that is indistinguishable from the first one only repeats the mistake faster. I set the client's internal retries to zero, so every retry in the Actor now goes through one place where pacing and session rotation are enforced:

const fetcher = new HttpFetcher({
  minDelayMs: 6_000, // ≤10 requests/min per address, the pacing the README promises
  retries: 0, // the client must not retry on its own: no pacing, same address, no rotation
});

The two economic properties are what a future regression would break silently, so they're pinned down in tests (condensed from the real suite; runOnBodies is a test harness that feeds canned HTML bodies through the full pipeline):

test('a persistent impostor page exhausts retries and fails the task', async () => {
  const { stats, requests, rotations } = await runOnBodies([fakeEmptyListingHtml], {
    subreddits: ['programming'],
  });
  assert.equal(requests, 4); // initial attempt + 3 retries
  assert.equal(rotations, 3); // every retry left from a fresh proxy session
  assert.equal(stats.failed, 1); // the task fails loudly, so no silent loss remains
});

test('an honestly empty page costs exactly one request', async () => {
  // the marker form is shared between listings and profiles, so one fixture serves both
  const { stats, requests } = await runOnBodies([emptyProfileHtml], {
    users: ['Background_Creme_562'],
  });
  assert.equal(requests, 1); // one request, not four
  assert.equal(stats.ok, 1); // and it's a success: the page really has nothing
  assert.equal(stats.items, 0);
});

The second test is the one I'd defend in a code review, because it asserts that an honest empty stays cheap. Reliability fixes have a way of quietly taxing the well-behaved case, and "your empty profile now costs four requests and fails" would have been exactly that tax.

There is a final backstop above the per-task logic. If a run ends with every task failed and nothing delivered, the Actor calls Actor.fail() and exits FAILED, which is what wakes up monitoring, because a failed status trips alerts and a quiet zero wakes nothing. After this change, a green run with an empty dataset can mean only two things, both of them honest: either every requested page carried Reddit's own "nothing here" signature, or the caller's own filters (dates, includeNSFW, maxItems) excluded everything the pages contained.

The empty dataset count, after

I re-ran the same 50-scenario gate on the fixed build, with the same scenario set, the same platform, and the same pacing:

  • 50 of 50 runs SUCCEEDED, every internal task succeeded, median run 5.0 seconds.
  • 2,545 items versus 1,354 on the identical scenario set, which is 88% more data, none of it new and all of it previously dropped. The two age-flagged profiles, their question answered, contributed their 3 and 25 posts.
  • Empty datasets: exactly one, the single profile where Reddit itself renders "there doesn't seem to be anything here". The count of empty runs now equals the count of genuinely empty scenarios, which is the equality the whole exercise was about.
  • Five retries across the 50 runs, the price of re-fetching impostor pages and a single-digit-percentage overhead on requests.
  • Honestly empty sources still cost one request each.

The gate's headline number, success rate, was 100% before the fix and 100% after. The metric I had designed to protect buyers missed the worst thing happening to them. The number that moved was one I hadn't thought to define: empty runs against genuinely empty scenarios, 13-to-3 before (and the 3 was really 1), and 1-to-1 after. My gate now checks both.

The trade I accepted

The classifier leans on the exact text and markup of Reddit's emptiness marker. Markup shifts, and old.reddit's has been stable for years, but it isn't mine to keep stable. If the marker is ever renamed, genuinely empty pages will stop matching bucket 2 and start classifying as impostors: three futile retries and then a failed task, all for a correct empty answer.

I took that trade with open eyes, because the two failure directions are not symmetric. A wrong FAILED is noisy: the buyer sees it, my alerts fire on it, and the canary run I keep on a six-hour schedule trips over it within hours. A wrong SUCCEEDED is silent: it survives 50-run release gates, as I have the receipts to prove, and it would have sat in production misinforming buyers indefinitely. When a dependency forces you to choose which way your system degrades, choose the direction someone will notice.

The marker dependency is fenced in the test suite by an empty-search fixture captured live, an empty-listing fixture carrying the marker byte for byte from a live empty page, and the one-request test above, so a future markup change breaks a named test rather than a buyer's pipeline.

If you publish Actors: enumerate your empty states

Everything above compresses into a short list, and none of it is Reddit-specific. The same taxonomy applies to any target: e-commerce sites serve "0 results" pages that are really consent walls, region blocks render as empty category listings, and search endpoints return polite empty shells when throttled.

  1. "No data" is a taxonomy rather than a boolean. Genuinely empty, substituted, an interstitial question, and filtered to zero by your own inputs are four different states, each of which needs different handling, so before you trust a zero, work out which one you are holding. Leave room for the states you haven't met yet: mine went from two to three in one afternoon.
  2. Find the target's own declaration of emptiness and require it. Most sites render something when a page is legitimately empty, and making that marker a precondition for recording zero items as a success is what turns a guess into a check.
  3. Classify on raw page contents, before your filters run. Your own maxItems and date filters legitimately produce zero rows from full pages, so classification belongs upstream of them.
  4. Make every other zero loud. Unexplained emptiness is a transient failure, so retry it like one, and if a whole run delivers nothing without a declared-empty witness, fail the run. The status field is your API contract, and an agent reading it has no other signal to reason from.
  5. Own your retries in one place, with the HTTP client's built-ins disabled, and assert the economics in tests: one test that an impostor fails loudly, and one that an honest empty costs a single request. The second is what stops a reliability fix from taxing your best-behaved users.

My Actor's success rate said 100% while a quarter of its runs returned nothing the buyer had asked for. A green run is a claim your Actor makes on your behalf, to humans who might re-check it and to agents who won't, so it should be a claim the Actor can defend.

If you have hit your own flavor of the 200 that wasn't, whether it was a consent wall counted as an empty category or a soft block shaped like a valid page, I'd like to hear how you detect it, and what your target's version of "there doesn't seem to be anything here" turned out to be.

Apify logo
Apify is a marketplace of ready-to-run tools for AI
Thousands of Actors to automate your business. Get real-time web data, track competitors, generate leads, monitor social media, and integrate your apps and agents.

Measurements taken on August 8, 2026: two 50-run release gates on the Apify platform (builds 0.1.2 and 0.1.3 of the Actor), a 29-request replay audit of the 13 empty scenarios, and live capture of both emptiness-marker forms. The Actor is Reddit Data Scraper, pay-per-event with no start fee. Page-structure details are as observed on old.reddit.com on those dates; the markup isn't mine to keep stable, which is what the fixtures are for.

On this page

Don't build it. Find it.

Thousands of ready-to-run tools for AI.

Browse Apify Store