{"record":{"id":"c3a738d662573074","repo":"jackwener/OpenCLI","slug":"xiaohongshu-location-filter-was-not-applied-det","errorCode":null,"errorMessage":"Xiaohongshu location filter was not applied (${detail}); enable browser geolocation permission.","messagePattern":"Xiaohongshu location filter was not applied \\((.+?)\\); enable browser geolocation permission\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/search.js","lineNumber":513,"sourceCode":"}\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\n * ~5-7 notes per scroll, so the previous `times: 2` capped extraction at\n * ~13 items regardless of `--limit` (see #1471). This helper drives scrolls\n * dynamically:\n *\n *   - count visible `section.note-item` rows (excluding related-search\n *     `.query-note-item` rows)","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/search.js#L495-L531","documentation":"When the filter-application script reports status 'location', requireFilterApplication throws this CommandExecutionError explaining that the location filter could not be applied. Applying Xiaohongshu's location/nearby filter depends on the browser granting geolocation permission, and the script detected the filter did not take effect.","triggerScenarios":"The in-page script returns {status:'location', detail:...} when the location filter chip/panel failed to apply — typically because the browser context denied or never prompted for geolocation permission for www.xiaohongshu.com.","commonSituations":"Headless browsers with geolocation disabled by default; browser profiles where the site's location permission was previously blocked; running in a container/CI with no location providers; desktop environments without geolocation services.","solutions":["Grant www.xiaohongshu.com geolocation permission in the browser profile used by the CLI (Site Settings → Location → Allow)","Launch the browser with a fake geolocation (e.g. Playwright/Puppeteer context option granting permissions and setting coordinates)","Drop the location filter from the search arguments if precise location is not required","Verify the filter actually matters for your query — other filters work without geolocation"],"exampleFix":"// before\nawait context.newPage(); // headless, no geolocation permissions\n// after\nconst context = await browser.newContext({\n  geolocation: { latitude: 31.2304, longitude: 121.4737 },\n  permissions: ['geolocation'],\n});","handlingStrategy":"fallback","validationCode":"// Pre-check geolocation support in your browser context before using the location filter\nconst canGeolocate = await page.evaluate(() => 'geolocation' in navigator);\nif (!canGeolocate) throw new Error('browser context cannot provide geolocation; skip the location filter');","typeGuard":null,"tryCatchPattern":"try {\n  await collectSearchHarvest(query, { ...filters, location: 'nearby' });\n} catch (e) {\n  if (e.message.includes('location filter was not applied')) {\n    return collectSearchHarvest(query, { ...filters, location: undefined }); // retry without location\n  }\n  throw e;\n}","preventionTips":["Launch the browser context with geolocation permission and explicit coordinates","Never rely on default headless settings for location-dependent filters","Pre-grant site permissions in the persistent browser profile for www.xiaohongshu.com","Make the location filter optional in your workflow with a graceful fallback"],"tags":["geolocation","browser-permissions","filters","headless"],"backgroundTag":"browser-permission-denied","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}