jackwener/OpenCLI · error · ArgumentError

tieba search currently only supports --page ${MAX_SUPPORTED_

Error message

tieba search currently only supports --page ${MAX_SUPPORTED_PAGE}

What it means

`tieba search` supports only one fixed page (`MAX_SUPPORTED_PAGE`) because Baidu Tieba's desktop search UI no longer offers stable browser pagination. `assertSupportedPage` runs before the search and throws an ArgumentError for any `--page` value other than that single supported value. This is a deliberate API restriction, not a transient failure.

Source

Thrown at clis/tieba/search.js:79

    })()
  `;
}
/**
 * Normalize CLI args into the concrete search page URL.
 */
function getSearchUrl(kwargs) {
    const keyword = String(kwargs.keyword || '');
    const pageNumber = Number(kwargs.page || 1);
    return `https://tieba.baidu.com/f/search/res?qw=${encodeURIComponent(keyword)}&ie=utf-8&pn=${pageNumber}`;
}
/**
 * Tieba's current desktop search UI no longer exposes a reliable browser-page transition.
 */
function assertSupportedPage(kwargs) {
    const pageNumber = String(kwargs.page || 1);
    if (pageNumber === MAX_SUPPORTED_PAGE)
        return;
    throw new ArgumentError(`tieba search currently only supports --page ${MAX_SUPPORTED_PAGE}`, `Baidu Tieba search no longer exposes stable browser pagination; omit --page or use --page ${MAX_SUPPORTED_PAGE}`);
}
cli({
    site: 'tieba',
    name: 'search',
    access: 'read',
    description: 'Search posts across tieba',
    domain: 'tieba.baidu.com',
    strategy: Strategy.COOKIE,
    browser: true,
    navigateBefore: false,
    args: [
        { name: 'keyword', positional: true, required: true, type: 'string', help: 'Search keyword' },
        // Restrict unsupported pages before the browser session starts.
        { name: 'page', type: 'int', default: 1, choices: ['1'], help: 'Page number (currently only 1 is supported)' },
        { name: 'limit', type: 'int', default: 20, help: 'Number of items to return' },
    ],
    columns: ['rank', 'id', 'title', 'forum', 'author', 'time', 'url'],
    func: async (page, kwargs) => {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Omit the --page flag entirely so the search uses its single supported page.
  2. Use the documented value exactly: `--page <MAX_SUPPORTED_PAGE>` as stated in the error hint.
  3. To get more results, refine the query (tighter keywords, forum filter) or paginate via different query terms instead of --page.
  4. Check the installed library version — newer releases may restore pagination; upgrade if available.

Example fix

// before
await cli.search({ query: 'linux', page: 3 }); // ArgumentError
// after
await cli.search({ query: 'linux' }); // omit --page
// or, if you need more results:
await cli.search({ query: 'linux kernel config' });
Defensive patterns

Strategy: validation

Validate before calling

// assert supported page before invoking tieba search
const ALLOWED_PAGE = 1; // MAX_SUPPORTED_PAGE
if (page !== undefined && page !== ALLOWED_PAGE) {
  throw new Error(`tieba search only supports --page ${ALLOWED_PAGE}`);
}

Type guard

function isSupportedSearchPage(page) {
  return page === undefined || page === 1; // matches MAX_SUPPORTED_PAGE
}

Try / catch

try {
  return await cli.search({ query, page });
} catch (e) {
  if (/only supports --page/.test(e.message)) {
    return cli.search({ query }); // drop --page and retry
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling `tieba search --query <q> --page N` (or kwargs.page) where the stringified page differs from MAX_SUPPORTED_PAGE — e.g. `--page 2`, `--page 3`, or any value other than the allowed one; omitting --page defaults to 1 and likewise throws unless MAX_SUPPORTED_PAGE is '1'.

Common situations: Scripts written when real pagination existed; developers assuming Google-like pagination semantics; loops that increment --page to fetch more results.

Related errors


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