jackwener/OpenCLI · error · AuthRequiredError

Trip.com is asking for a verification; complete it in your b

Error message

Trip.com is asking for a verification; complete it in your browser session and retry

What it means

This AuthRequiredError from clis/trip/hotel-search.js is thrown when WAIT_FOR_HOTELS_JS returns 'captcha' after navigating to the hotel search URL, meaning Trip.com served a verification challenge instead of hotel cards. Like the flight equivalent, it tells the caller that the shared browser session needs human verification before scraping can continue. Immediate blind retries typically just trigger the challenge again.

Source

Thrown at clis/trip/hotel-search.js:55

        'name', 'score', 'reviewLabel', 'reviews',
        'location', 'room',
        'price', 'currency',
        'url',
    ],
    func: async (page, kwargs) => {
        const cityId = parseCityId('city', kwargs.city);
        const checkin = parseIsoDate('checkin', kwargs.checkin);
        const checkout = parseIsoDate('checkout', kwargs.checkout);
        if (checkin >= checkout) {
            throw new ArgumentError(`--checkin must be before --checkout (got ${checkin} .. ${checkout})`);
        }
        const limit = parseListLimit(kwargs.limit);

        const searchUrl = buildHotelSearchUrl(cityId, checkin, checkout);
        await page.goto(searchUrl);
        const waitResult = await page.evaluate(WAIT_FOR_HOTELS_JS);
        if (waitResult === 'captcha') {
            throw new AuthRequiredError('trip.com', 'Trip.com is asking for a verification; complete it in your browser session and retry');
        }
        if (waitResult !== 'content') {
            throw new CommandExecutionError(`Trip.com hotel page did not render hotel cards (state=${String(waitResult)})`);
        }
        const raw = await page.evaluate(buildHotelExtractJs());
        if (!Array.isArray(raw)) {
            throw new CommandExecutionError('Trip.com hotel DOM extraction returned malformed rows');
        }
        if (raw.length === 0) {
            throw new EmptyResultError('trip hotel-search', `No hotels for city ${cityId} on ${checkin} .. ${checkout}`);
        }
        return raw.slice(0, limit).map((r, i) => ({
            rank: i + 1,
            name: r.name,
            score: r.score,
            reviewLabel: r.reviewLabel,
            reviews: r.reviews,
            location: r.location,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Complete the CAPTCHA manually in the same browser session, then rerun the command.
  2. Throttle searches and add randomized delays between runs.
  3. Switch to a residential IP and disable VPN/proxy for the session.
  4. Use a persistent, cookie-warmed browser profile instead of ephemeral contexts.

Example fix

// before
await runTripHotelSearch(args); // throws AuthRequiredError on captcha
// after
try {
  await runTripHotelSearch(args);
} catch (e) {
  if (e.name === 'AuthRequiredError') {
    await pauseForManualCaptcha(page);
    await runTripHotelSearch(args);
  } else throw e;
}
Defensive patterns

Strategy: retry

Validate before calling

// Server-side captcha cannot be pre-checked; pace calls instead:
await sleep(3000 + Math.random() * 5000); // jittered spacing between hotel searches

Type guard

const isAuthRequired = (e) => e?.name === 'AuthRequiredError' || e instanceof AuthRequiredError;

Try / catch

try {
  await runTripHotelSearch(args);
} catch (e) {
  if (isAuthRequired(e)) {
    await waitForManualCaptchaResolution(page);
    return runTripHotelSearch(args); // single retry post-verification
  }
  throw e;
}

Prevention

When it happens

Trigger: page.evaluate(WAIT_FOR_HOTELS_JS) after page.goto(buildHotelSearchUrl(...)) returns exactly 'captcha'.

Common situations: Bursts of hotel searches from the same session/IP; fresh headless browser profiles without cookies; VPN or datacenter IPs flagged by Trip.com; aggressive automated scheduling hitting the site repeatedly.

Related errors


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