jackwener/OpenCLI · error · CommandExecutionError

Xiaohongshu location filter was not applied (${detail}); ena

Error message

Xiaohongshu location filter was not applied (${detail}); enable browser geolocation permission.

What it means

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.

Source

Thrown at clis/xiaohongshu/search.js:513

}

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
 * ~5-7 notes per scroll, so the previous `times: 2` capped extraction at
 * ~13 items regardless of `--limit` (see #1471). This helper drives scrolls
 * dynamically:
 *
 *   - count visible `section.note-item` rows (excluding related-search
 *     `.query-note-item` rows)

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Grant www.xiaohongshu.com geolocation permission in the browser profile used by the CLI (Site Settings → Location → Allow)
  2. Launch the browser with a fake geolocation (e.g. Playwright/Puppeteer context option granting permissions and setting coordinates)
  3. Drop the location filter from the search arguments if precise location is not required
  4. Verify the filter actually matters for your query — other filters work without geolocation

Example fix

// before
await context.newPage(); // headless, no geolocation permissions
// after
const context = await browser.newContext({
  geolocation: { latitude: 31.2304, longitude: 121.4737 },
  permissions: ['geolocation'],
});
Defensive patterns

Strategy: fallback

Validate before calling

// Pre-check geolocation support in your browser context before using the location filter
const canGeolocate = await page.evaluate(() => 'geolocation' in navigator);
if (!canGeolocate) throw new Error('browser context cannot provide geolocation; skip the location filter');

Try / catch

try {
  await collectSearchHarvest(query, { ...filters, location: 'nearby' });
} catch (e) {
  if (e.message.includes('location filter was not applied')) {
    return collectSearchHarvest(query, { ...filters, location: undefined }); // retry without location
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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