jackwener/OpenCLI · warning · CliError

NO_DATA

NO_DATA

Error message

No recommended jobs returned

What it means

The hot-jobs API call succeeded (status '1') but the response contained zero items in resultbody.job.items, so the library throws CliError('NO_DATA'). The API worked; it simply returned no recommended jobs for the given filters.

Source

Thrown at clis/51job/hot.js:53

        const pageNum = Math.max(1, Number(kwargs.page) || 1);
        const jobArea = resolveCity(kwargs.area);
        const sortType = resolveCode(kwargs.sort, SORT_CODES, '0');

        const currentUrl = await page.evaluate(`(() => window.location.href)()`);
        if (!String(currentUrl).startsWith(WE_ORIGIN)) {
            await navigateTo(page, `${WE_ORIGIN}/pc/search?searchType=2`, 2);
        }

        const url = buildSearchUrl({
            keyword: '', jobArea, sortType,
            pageNum, pageSize: Math.min(limit, 50),
        });
        const data = await pageFetchJson(page, url);
        if (data.status !== '1' && data.status !== 1) {
            throw new CliError('API_ERROR', `51job hot failed: ${data.message ?? 'unknown'}`);
        }
        const items = data?.resultbody?.job?.items ?? [];
        if (items.length === 0) throw new CliError('NO_DATA', 'No recommended jobs returned');
        return items.slice(0, limit).map((it, i) => mapJobItem(it, (pageNum - 1) * limit + i + 1));
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry at page 1 without restrictive filters to confirm data exists
  2. Check the jobArea code is a real 51job city code
  3. Stop pagination when this error appears — it signals the end of results
  4. Retry later; the recommendation feed can be transiently empty

Example fix

// before
const jobs = await cli.hot({ page: deepPage });
// after
try {
  return await cli.hot({ page: deepPage });
} catch (e) {
  if (e.code === 'NO_DATA') return []; // end of results
  throw e;
}
Defensive patterns

Strategy: fallback

Validate before calling

if (!Number.isInteger(page) || page < 1) throw new Error('page must be a positive integer');

Type guard

const hasItems = (d) => Array.isArray(d?.resultbody?.job?.items) && d.resultbody.job.items.length > 0;

Try / catch

try {
  return await cli.hot({ jobArea, page });
} catch (e) {
  if (e.code === 'NO_DATA') return []; // empty page — end of results
  throw e;
}

Prevention

When it happens

Trigger: Calling the hot subcommand with filters (jobArea, sortType, page) that match no jobs — e.g. an obscure city code, a page number beyond the last page, or a sortType with no results — thrown at clis/51job/hot.js:53.

Common situations: Paging past the end of the result set during batch crawls; filtering to a small/remote city with no recommendations; API returning empty during low-traffic periods or for unauthenticated/flagged sessions.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/1f25774e74ff7b4a. Report an issue: GitHub.