jackwener/OpenCLI · error · AuthRequiredError
Ctrip is asking for a captcha; complete it in your browser s
Error message
Ctrip is asking for a captcha; complete it in your browser session and retry
What it means
An AuthRequiredError thrown when the wait-for-content script running inside the Ctrip round-trip flight page detects Ctrip's captcha challenge (waitResult === 'captcha'). The CLI drives a logged-in Chrome/Chromium session and cannot solve captchas itself, so it defers to the user: solve the captcha in that browser session and retry the command.
Source
Thrown at clis/ctrip/flight-round.js:84
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 depart = parseIsoDate('depart', kwargs.depart);
const ret = parseIsoDate('return', kwargs.return);
if (ret < depart) {
throw new ArgumentError(`--return (${ret}) must be on or after --depart (${depart})`);
}
const limit = parseListLimit(kwargs.limit);
const searchUrl =
`https://flights.ctrip.com/online/list/round-${fromCode.toLowerCase()}-${toCode.toLowerCase()}` +
`?depdate=${depart}_${ret}&cabin=Y_S_C_F&adult=1&child=0&infant=0`;
await page.goto(searchUrl);
const waitResult = await page.evaluate(WAIT_FOR_FLIGHTS_ROUND_JS);
if (waitResult === 'captcha') {
throw new AuthRequiredError('flights.ctrip.com', 'Ctrip is asking for a captcha; complete it in your browser session and retry');
}
if (waitResult !== 'content') {
throw new CommandExecutionError(`Ctrip round-trip flight page did not render flight cards (state=${String(waitResult)})`);
}
const renderedCardCount = await page.evaluate(buildScrollUntilJs(ROUND_CARD_SELECTOR, limit));
const raw = await page.evaluate(buildFlightExtractJs(ROUND_CARD_SELECTOR, false));
if (!Array.isArray(raw)) {
throw new CommandExecutionError('Ctrip round-trip flight DOM extraction returned malformed rows');
}
if (raw.length === 0) {
if (Number(renderedCardCount) > 0) {
throw new CommandExecutionError('Ctrip round-trip flight cards rendered but parser did not find required flight anchors');
}
throw new EmptyResultError('ctrip flight-round', `No round-trip flights for ${fromCode}→${toCode} on ${depart} / ${ret}`);
}
const completeRows = raw
.filter((r) => r.departureTime && r.departureAirport && r.arrivalTime && r.arrivalAirport && r.airline)
.slice(0, limit)View on GitHub (pinned to 49907e53dc)
Solutions
- Open the Ctrip page in the same Chrome/Chromium session the CLI uses and complete the captcha manually, then rerun the command.
- Log in to flights.ctrip.com in that browser to establish trusted cookies before retrying.
- Slow down request cadence, add delays between CLI invocations, or run from a residential IP.
- If captchas recur constantly, reduce automation volume or use a different authenticated profile.
Example fix
// before (naive loop that keeps hitting captcha)
for (const d of dates) cli(['flight-round', ..., '--depart', d, '--return', addDays(d)]);
// after
for (const d of dates) {
try { cli(['flight-round', ...]); } catch (e) {
if (e instanceof AuthRequiredError) { promptUserToSolveCaptcha('flights.ctrip.com'); retryOnce(); }
else throw e;
}
await sleep(5000);
} Defensive patterns
Strategy: retry
Type guard
function isAuthRequiredError(e) { return e && (e.code === 'AUTH_REQUIRED' || e instanceof AuthRequiredError); } Try / catch
try { await cli(['flight-round', ...]); }
catch (e) {
if (isAuthRequiredError(e)) { openBrowserForCaptcha('flights.ctrip.com'); return retryOnce(); }
throw e;
} Prevention
- Keep the CLI's Chrome profile logged in to flights.ctrip.com before batch runs.
- Throttle commands; avoid tight loops against Ctrip.
- Run from a stable residential IP rather than datacenter IPs.
- Alert on AUTH_REQUIRED exit code so operators solve captchas promptly.
When it happens
Trigger: page.goto to the round-trip flight search URL renders a captcha instead of flight cards — Ctrip's anti-bot has flagged the automated browser session and WAIT_FOR_FLIGHTS_ROUND_JS returns 'captcha'.
Common situations: Repeated rapid scraping from one IP; running many commands back-to-back in CI; a fresh browser profile with no Ctrip cookies triggering bot detection; Ctrip escalating risk checks during peak booking times.
Related errors
- Ctrip is asking for a captcha; complete it in your browser s
- Ctrip is asking for a captcha; complete it in your browser s
- Ctrip is asking for a captcha; complete it in your browser s
- Ctrip is asking for a captcha; complete it in your browser s
- Ctrip flight API returned HTTP ${status}; complete any verif
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/06c79354aca81cd2.
Report an issue: GitHub.