jackwener/OpenCLI · error · AuthRequiredError

Xiaohongshu search filters require a logged-in browser…

Error message

Xiaohongshu search filters require a logged-in browser session

What it means

When the filter-application script reports status 'auth', requireFilterApplication raises this AuthRequiredError for www.xiaohongshu.com. Many Xiaohongshu search filters (sort options, account-scoped facets) are only usable while logged in, so the library surfaces an explicit authentication requirement instead of failing opaquely.

Solutions

  1. Log in to www.xiaohongshu.com in the browser profile the CLI uses, then re-run the search
  2. Point the CLI at a persistent browser user-data dir that retains the session cookie
  3. Re-login if the session expired (check for redirect to /login in the page)
  4. Avoid filters that require auth when scraping anonymously, or handle AuthRequiredError and prompt the user

Example fix

// before
const rows = await harvestSearch(query, { sort: 'newest' }); // throws AuthRequiredError
// after
try {
  const rows = await harvestSearch(query, { sort: 'newest' });
} catch (e) {
  if (e instanceof AuthRequiredError) {
    console.error('Please log in to xiaohongshu.com in the browser profile, then retry.');
    process.exitCode = 2;
    return;
  }
  throw e;
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await collectSearchHarvest(query, filters);
} catch (e) {
  if (e instanceof AuthRequiredError && e.host === 'www.xiaohongshu.com') {
    console.error('Login to xiaohongshu.com required; open the browser profile and log in, then retry.');
    process.exitCode = 2;
  } else throw e;
}

Prevention

When it happens

Trigger: The in-page filter script detects the page was redirected to a login flow, or filter chips are absent/inert because the session is anonymous, and it returns {status:'auth'}.

Common situations: Running the search without a logged-in browser profile, an expired xiaohongshu.com session cookie, using a fresh/incognito browser context, or anti-bot measures invalidating the session mid-run.

Related errors


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

Appendix: source

Thrown at clis/xiaohongshu/search.js:507

            return { status: 'inactive', detail: request.group + '/' + request.option };
          }
        }
        return { status: 'ok' };
      })()
    `;
}

function requireFilterApplication(payload) {
    const result = unwrapEvaluateResult(payload);
    if (!result || typeof result !== 'object' || Array.isArray(result) || typeof result.status !== 'string') {
        throw new CommandExecutionError('Unexpected Xiaohongshu search filter result shape.');
    }
    if (result.status === 'ok') {
        return;
    }
    const detail = typeof result.detail === 'string' ? result.detail : 'unknown';
    if (result.status === 'auth') {
        throw new AuthRequiredError('www.xiaohongshu.com', 'Xiaohongshu search filters require a logged-in browser session');
    }
    if (result.status === 'timeout') {
        throw new TimeoutError(`xiaohongshu search filter ${detail}`, FILTER_SETTLE_SECONDS);
    }
    if (result.status === 'location') {
        throw new CommandExecutionError(`Xiaohongshu location filter was not applied (${detail}); enable browser geolocation permission.`);
    }
    if (result.status === 'capability') {
        throw new CommandExecutionError(`Xiaohongshu account-scoped filter was unavailable (${detail}); verify login and account access.`);
    }
    if (result.status === 'inactive') {
        throw new CommandExecutionError(`Xiaohongshu search filter chip did not become active (${detail}).`);
    }
    throw new CommandExecutionError(`Xiaohongshu search filter layout did not match the expected visible panel (${detail}).`);
}
/**
 * Build a "scroll until enough or plateaued" IIFE used in place of a fixed
 * `autoScroll({ times: N })`. Xiaohongshu's search results page lazy-loads

View on GitHub (pinned to 49907e53dc)