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 is raised when WAIT_FOR_HOTEL_DETAIL_JS reports state 'captcha' after navigating to the hotel detail URL — Trip.com served a bot-verification (captcha) challenge instead of the SSR hotel content. The library refuses to bypass it and asks you to clear the challenge in a logged-in browser session and retry.

Source

Thrown at clis/trip/hotel.js:40

    browser: true,
    navigateBefore: false,
    args: [
        { name: 'id', required: true, positional: true, help: 'Numeric Trip.com hotel id (discover via the hotels list; e.g. 715233)' },
    ],
    columns: [
        'hotelId', 'name', 'enName',
        'star', 'score', 'scoreLabel', 'reviewCount', 'ratingBreakdown',
        'facilities', 'checkInOut',
        'cityName', 'address', 'lat', 'lon',
        'url',
    ],
    func: async (page, kwargs) => {
        const hotelId = parseHotelId('id', kwargs.id);
        const url = buildHotelDetailUrl(hotelId);
        await page.goto(url);
        const waitResult = await page.evaluate(WAIT_FOR_HOTEL_DETAIL_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 detail page did not expose SSR hotel data (state=${String(waitResult)})`);
        }
        const detail = await page.evaluate(buildHotelDetailExtractJs());
        if (!detail || typeof detail !== 'object') {
            throw new CommandExecutionError('Trip.com hotel detail SSR extraction returned malformed data');
        }
        if (!detail.hotelId || !detail.name) {
            throw new EmptyResultError('trip hotel', `No detail exposed for hotel id ${hotelId}`);
        }
        return [{ ...detail, url }];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open the Trip.com session in a normal browser, complete the verification, then retry the command
  2. Reuse a persistent browser profile with valid Trip.com cookies instead of a clean headless session
  3. Slow down request rate and add delays between hotel detail requests
  4. Switch to a residential IP or different network if the current IP is flagged

Example fix

// before
await tripHotelDetail({ id: hotelId }); // fails with captcha
// after
// 1) clear captcha in your interactive browser session
// 2) rerun with the same profile/cookies
await tripHotelDetail({ id: hotelId, profile: 'my-session' });
Defensive patterns

Strategy: retry

Validate before calling

if (!process.env.TRIP_SESSION_COOKIES) {
  console.warn('No Trip.com session cookies set — captcha risk is high');
}

Try / catch

try {
  return await tripHotelDetail({ id });
} catch (e) {
  if (e instanceof AuthRequiredError) {
    await promptCaptchaResolution(); // complete verification in browser
    return await tripHotelDetail({ id }); // retry once with same session
  }
  throw e;
}

Prevention

When it happens

Trigger: page.goto(buildHotelDetailUrl(hotelId)) lands on a verification page: the session cookie is missing/expired, the IP is flagged, request rate is too high, or no browser fingerprint/cookies accompany the request.

Common situations: Headless sessions with no shared cookies, datacenter IPs flagged by Trip.com, rapid successive hotel-detail scrapes, or reusing an expired session profile.

Related errors


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