{"record":{"id":"207cdc48d6ea24b4","repo":"jackwener/OpenCLI","slug":"xiaohongshu-search-filters-require-a-logged-in-bro","errorCode":null,"errorMessage":"Xiaohongshu search filters require a logged-in browser session","messagePattern":"Xiaohongshu search filters require a logged-in browser session","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/search.js","lineNumber":507,"sourceCode":"            return { status: 'inactive', detail: request.group + '/' + request.option };\n          }\n        }\n        return { status: 'ok' };\n      })()\n    `;\n}\n\nfunction requireFilterApplication(payload) {\n    const result = unwrapEvaluateResult(payload);\n    if (!result || typeof result !== 'object' || Array.isArray(result) || typeof result.status !== 'string') {\n        throw new CommandExecutionError('Unexpected Xiaohongshu search filter result shape.');\n    }\n    if (result.status === 'ok') {\n        return;\n    }\n    const detail = typeof result.detail === 'string' ? result.detail : 'unknown';\n    if (result.status === 'auth') {\n        throw new AuthRequiredError('www.xiaohongshu.com', 'Xiaohongshu search filters require a logged-in browser session');\n    }\n    if (result.status === 'timeout') {\n        throw new TimeoutError(`xiaohongshu search filter ${detail}`, FILTER_SETTLE_SECONDS);\n    }\n    if (result.status === 'location') {\n        throw new CommandExecutionError(`Xiaohongshu location filter was not applied (${detail}); enable browser geolocation permission.`);\n    }\n    if (result.status === 'capability') {\n        throw new CommandExecutionError(`Xiaohongshu account-scoped filter was unavailable (${detail}); verify login and account access.`);\n    }\n    if (result.status === 'inactive') {\n        throw new CommandExecutionError(`Xiaohongshu search filter chip did not become active (${detail}).`);\n    }\n    throw new CommandExecutionError(`Xiaohongshu search filter layout did not match the expected visible panel (${detail}).`);\n}\n/**\n * Build a \"scroll until enough or plateaued\" IIFE used in place of a fixed\n * `autoScroll({ times: N })`. Xiaohongshu's search results page lazy-loads","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/search.js#L489-L525","documentation":"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.","triggerScenarios":"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'}.","commonSituations":"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.","solutions":["Log in to www.xiaohongshu.com in the browser profile the CLI uses, then re-run the search","Point the CLI at a persistent browser user-data dir that retains the session cookie","Re-login if the session expired (check for redirect to /login in the page)","Avoid filters that require auth when scraping anonymously, or handle AuthRequiredError and prompt the user"],"exampleFix":"// before\nconst rows = await harvestSearch(query, { sort: 'newest' }); // throws AuthRequiredError\n// after\ntry {\n  const rows = await harvestSearch(query, { sort: 'newest' });\n} catch (e) {\n  if (e instanceof AuthRequiredError) {\n    console.error('Please log in to xiaohongshu.com in the browser profile, then retry.');\n    process.exitCode = 2;\n    return;\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await collectSearchHarvest(query, filters);\n} catch (e) {\n  if (e instanceof AuthRequiredError && e.host === 'www.xiaohongshu.com') {\n    console.error('Login to xiaohongshu.com required; open the browser profile and log in, then retry.');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Use a persistent browser profile with an active xiaohongshu.com session","Check session validity (e.g. load the profile page) before running filtered searches","Detect login-page redirects early and prompt for re-auth instead of scraping","Avoid auth-gated filters when operating an anonymous session"],"tags":["authentication","session","scraping","xiaohongshu"],"backgroundTag":"auth-required-login-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}