jackwener/OpenCLI · warning · EmptyResultError
No flights for ${fromCode} to ${toCode} on ${date}
Error message
No flights for ${fromCode} to ${toCode} on ${date} What it means
This EmptyResultError from clis/trip/flight.js is thrown when the one-way flight extraction succeeded (returned a valid array) but contained zero rows for the requested from/to/date. The command worked; Trip.com simply listed no flights for that route and day. It is the canonical 'no results' outcome for the flight command and should be handled as an empty result, not a failure.
Source
Thrown at clis/trip/flight.js:71
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,
departureTime: r.departureTime,
departureAirport: r.departureAirport,
arrivalTime: r.arrivalTime,
arrivalAirport: r.arrivalAirport,
duration: r.duration,
stops: r.stops,
price: r.price,
currency: r.currency,
url: searchUrl,
}));
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Confirm the route/date shows flights on Trip.com in a normal browser.
- Check --date is a valid future ISO date within the booking window.
- Try adjacent dates or nearby alternate airports.
- Catch EmptyResultError and treat it as an empty list in the caller.
Example fix
// before
const flights = await runTripFlight({ from: 'JFK', to: 'LHR', date: '2020-01-01' });
// after
let flights;
try {
flights = await runTripFlight({ from: 'JFK', to: 'LHR', date: '2026-10-01' });
} catch (e) {
if (e instanceof EmptyResultError) flights = [];
else throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!/^[A-Z]{3}$/.test(from) || !/^[A-Z]{3}$/.test(to)) throw new Error('invalid IATA codes');
const d = new Date(date);
if (isNaN(d) || d < new Date()) throw new Error('date must be a future ISO date'); Type guard
const isEmptyResult = (e) => e instanceof EmptyResultError || e?.name === 'EmptyResultError';
Try / catch
try {
const flights = await runTripFlight(args);
} catch (e) {
if (isEmptyResult(e)) return [];
throw e;
} Prevention
- Validate codes and dates before invoking.
- Prefer dates within the standard booking window.
- Treat EmptyResultError as data, not failure, in aggregation scripts.
- Test alternate dates when a route returns empty.
When it happens
Trigger: raw from page.evaluate(buildFlightExtractJs()) is an array with length 0 for the built one-way search URL on the given date.
Common situations: No direct service between two airports on that date; dates in the past or beyond the booking window; very early-morning or holiday dates where results are sold out; misspelled airport codes that still resolve but route oddly.
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
- No round-trip flights for ${fromCode} to ${toCode} on ${depa
- ctrip flight-round
- No attractions for "${query}"
- Trip.com flight page did not render flight cards (state=${St
- Trip.com flight DOM extraction returned malformed rows${reas
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c1c5559f6fead133.
Report an issue: GitHub.