jackwener/OpenCLI · warning · EmptyResultError
ctrip flight-round
Error message
ctrip flight-round
What it means
This is the command label argument passed to EmptyResultError ('ctrip flight-round'); the thrown error's actual message becomes 'ctrip flight-round returned no data' with the hint about no round-trip flights for the route/dates. It fires when extraction returned a valid but empty array AND renderedCardCount was 0 — i.e. the page rendered no flight cards at all, so the CLI treats it as a genuine empty result rather than a parse failure.
Source
Thrown at clis/ctrip/flight-round.js:98
`?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)
.map((r, i) => ({
rank: i + 1,
airline: r.airline,
flightNo: r.flightNo,
aircraft: r.aircraft,
departureTime: r.departureTime,
departureAirport: r.departureAirport,
arrivalTime: r.arrivalTime,
arrivalAirport: r.arrivalAirport,
terminal: r.terminal,
price: r.price,
currency: r.currency,
cabin: r.cabin,
url: searchUrl,View on GitHub (pinned to 49907e53dc)
Solutions
- Verify the route/dates on flights.ctrip.com in a browser — confirm no flights genuinely exist.
- Adjust dates (search a window rather than a single day) or pick an alternative route.
- Catch EmptyResultError and handle it as an expected empty result in your automation.
- If flights clearly show in the browser but not via the CLI, suspect geo/risk-control gating of your session instead.
Example fix
// before
const rows = await cli(['flight-round', '--from', a, '--to', b, '--depart', d, '--return', r]); // crash on empty
// after
try { const rows = await cli([...]); if (!rows.length) showNoFlightsMessage(); }
catch (e) { if (e instanceof EmptyResultError) showNoFlightsMessage(); else throw e; } Defensive patterns
Strategy: try-catch
Validate before calling
const dep = new Date(departDate); const now = new Date();
if (isNaN(dep) || dep < new Date(now.toDateString())) throw new Error('depart date must be a valid future date'); Type guard
function isEmptyResultError(e) { return e && (e.code === 'EMPTY_RESULT' || e instanceof EmptyResultError); } Try / catch
try { const rows = await cli(['flight-round','--from',a,'--to',b,'--depart',d,'--return',r]); return rows; }
catch (e) { if (isEmptyResultError(e)) return []; throw e; } Prevention
- Confirm route and dates exist on flights.ctrip.com before automation.
- Handle the EMPTY_RESULT exit code as an expected empty outcome.
- Search nearby dates when the exact date may be sold out or unserved.
- Distinguish EmptyResultError from CommandExecutionError so parse bugs aren't mistaken for no-data.
When it happens
Trigger: Calling the ctrip flight-round command for a route/date pair where the round-trip list page renders zero flight cards (renderedCardCount === 0) and the extracted rows array is empty.
Common situations: Searching a route Ctrip doesn't fly; dates too far in advance or in the past; all-sold-out flights; route suspended; region/locale where the route isn't offered.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- Ctrip attraction links rendered but parser did not find requ
- No coaches for ${fromCity} to ${toCity} on ${date}
- No sailings for ${fromCity} to ${toCity} on ${date}
- ctrip search
- No tour packages for "${destination}"
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/7d3e6698e36aab1c.
Report an issue: GitHub.