jackwener/OpenCLI · warning · EmptyResultError

xiaoyuzhou history

Error message

xiaoyuzhou history

What it means

EmptyResultError for the 'xiaoyuzhou history' command: after pagination completed, zero history rows were collected. The library treats an empty history as an error rather than returning an empty list, so callers can distinguish 'no data' from a successful fetch.

Source

Thrown at clis/xiaoyuzhou/history.js:227

        if (!fetchAll && rows.length >= limit) break;
        if (page.next === null) {
            exhausted = true;
            break;
        }
        if (page.next === loadMoreKey || seenCursors.has(page.next)) {
            throw new CommandExecutionError('Xiaoyuzhou history pagination repeated the same cursor');
        }
        if (pageNumber === maxPages) {
            throw new CommandExecutionError(
                `Xiaoyuzhou history stopped at the --max-pages safety limit (${maxPages}) before reaching the end`,
            );
        }
        seenCursors.add(page.next);
        loadMoreKey = page.next;
    }

    if (rows.length === 0) {
        throw new EmptyResultError('xiaoyuzhou history', 'The logged-in account has no playback history');
    }
    if (fetchAll && !exhausted) {
        throw new CommandExecutionError('Xiaoyuzhou history archive did not reach the end of pagination');
    }
    return rows;
}

cli({
    site: 'xiaoyuzhou',
    name: 'history',
    access: 'read',
    description: 'List playback history for the logged-in Xiaoyuzhou account',
    domain: 'api.xiaoyuzhoufm.com',
    strategy: Strategy.LOCAL,
    browser: false,
    args: [
        { name: 'limit', type: 'int', default: DEFAULT_LIMIT, help: `Maximum rows to return (default ${DEFAULT_LIMIT}, max ${MAX_LIMIT}). Ignored with --all.` },
        { name: 'all', type: 'bool', default: false, help: 'Fetch every history page until the API cursor is exhausted.' },

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify with a raw authenticated request that the history endpoint really returns no entries.
  2. Check the account in the app/website to confirm history exists; if it does, inspect parsing against the current response shape.
  3. Handle EmptyResultError explicitly in your code when an empty history is an acceptable outcome.
  4. Re-authenticate if the credentials belong to an unexpected (new) account.

Example fix

// before
const rows = await fetchHistory({ limit: 50 });
console.log(rows);
// after
let rows;
try { rows = await fetchHistory({ limit: 50 }); }
catch (e) {
  if (e instanceof EmptyResultError) rows = [];
  else throw e;
}
console.log(rows);
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const rows = await fetchHistory(args);
} catch (e) {
  if (e instanceof EmptyResultError) {
    return []; // empty history is acceptable here
  }
  throw e;
}

Prevention

When it happens

Trigger: The logged-in account genuinely has no playback history; the history endpoint returns pages with zero entries; authentication succeeds but the account is new/reset; an API change moves entries to a different response field so parsing yields nothing.

Common situations: Freshly registered or wiped accounts; region/permission differences hiding history; API response shape changes silently emptying parsed entries; automated tests against empty accounts.

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/aab82185d962fa4b. Report an issue: GitHub.