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/flight.js is thrown when WAIT_FOR_FLIGHTS_JS, evaluated after page.goto(searchUrl), returns 'captcha', meaning Trip.com served a bot-verification challenge instead of flight content. The library surfaces it as an auth/session requirement: the shared browser session must pass human verification before scraping can proceed. It is not a code bug and retrying immediately without solving the challenge will fail again.

Source

Thrown at clis/trip/flight.js:57

        'arrivalTime', 'arrivalAirport',
        'duration', 'stops',
        'price', 'currency',
        'url',
    ],
    func: async (page, kwargs) => {
        const fromCode = parseIataCode('from', kwargs.from);
        const toCode = parseIataCode('to', kwargs.to);
        if (fromCode === toCode) {
            throw new ArgumentError(`--from and --to must differ (got ${fromCode})`);
        }
        const date = parseIsoDate('date', kwargs.date);
        const limit = parseListLimit(kwargs.limit);

        const searchUrl = buildFlightSearchUrl(fromCode, toCode, date);
        await page.goto(searchUrl);
        const waitResult = await page.evaluate(WAIT_FOR_FLIGHTS_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 flight page did not render flight cards (state=${String(waitResult)})`);
        }
        const raw = await page.evaluate(buildFlightExtractJs());
        if (!Array.isArray(raw)) {
            const reason = raw && typeof raw === 'object' && typeof raw.error === 'string'
                && /^malformed flight card \d+: [a-z /]+$/.test(raw.error)
                ? `: ${raw.error}`
                : '';
            throw new CommandExecutionError(`Trip.com flight DOM extraction returned malformed rows${reason}`);
        }
        if (raw.length === 0) {
            throw new EmptyResultError('trip flight', `No flights for ${fromCode} to ${toCode} on ${date}`);
        }
        return raw.slice(0, limit).map((r, i) => ({
            rank: i + 1,
            airline: r.airline,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open the same browser session interactively, complete the CAPTCHA, then rerun the command.
  2. Reduce request frequency and add delays between searches to lower the bot score.
  3. Use a residential IP / disable VPN or datacenter proxy for the browser session.
  4. Reuse a warmed-up persistent browser profile with existing Trip.com cookies instead of a fresh profile.

Example fix

// before
// headless fresh profile, 50 rapid searches in a loop
// after
// reuse persistent profile, throttle to 1 search / few seconds,
// and on AuthRequiredError pause and let the user solve the challenge
try {
  await runTripFlight(args);
} catch (e) {
  if (e.name === 'AuthRequiredError') {
    await openBrowserForManualVerification();
    await runTripFlight(args);
  } else throw e;
}
Defensive patterns

Strategy: retry

Validate before calling

// Pre-check not possible for server-side captcha; instead throttle before calling:
await sleep(2000 + Math.random() * 3000); // jitter between searches
if (Date.now() - lastSearchAt < MIN_INTERVAL_MS) throw new Error('rate limit yourself');

Type guard

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

Try / catch

try {
  await runTripFlight(args);
} catch (e) {
  if (isAuthRequired(e)) {
    await waitForManualCaptchaResolution(page); // user solves in browser
    return runTripFlight(args); // single retry after verification
  }
  throw e;
}

Prevention

When it happens

Trigger: page.evaluate(WAIT_FOR_FLIGHTS_JS) after navigating to the built flight search URL returns exactly 'captcha' — Trip.com presented a CAPTCHA/anti-bot interstitial instead of flight cards.

Common situations: Running many flight searches in quick succession from a datacenter or VPN IP; a browser profile with no prior Trip.com cookies; Trip.com tightening anti-bot rules; scraping during high-traffic periods.

Related errors


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