{"record":{"id":"c1c5559f6fead133","repo":"jackwener/OpenCLI","slug":"no-flights-for-fromcode-to-tocode-on-date","errorCode":null,"errorMessage":"No flights for ${fromCode} to ${toCode} on ${date}","messagePattern":"No flights for (.+?) to (.+?) on (.+?)","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/trip/flight.js","lineNumber":71,"sourceCode":"        const searchUrl = buildFlightSearchUrl(fromCode, toCode, date);\n        await page.goto(searchUrl);\n        const waitResult = await page.evaluate(WAIT_FOR_FLIGHTS_JS);\n        if (waitResult === 'captcha') {\n            throw new AuthRequiredError('trip.com', 'Trip.com is asking for a verification; complete it in your browser session and retry');\n        }\n        if (waitResult !== 'content') {\n            throw new CommandExecutionError(`Trip.com flight page did not render flight cards (state=${String(waitResult)})`);\n        }\n        const raw = await page.evaluate(buildFlightExtractJs());\n        if (!Array.isArray(raw)) {\n            const reason = raw && typeof raw === 'object' && typeof raw.error === 'string'\n                && /^malformed flight card \\d+: [a-z /]+$/.test(raw.error)\n                ? `: ${raw.error}`\n                : '';\n            throw new CommandExecutionError(`Trip.com flight DOM extraction returned malformed rows${reason}`);\n        }\n        if (raw.length === 0) {\n            throw new EmptyResultError('trip flight', `No flights for ${fromCode} to ${toCode} on ${date}`);\n        }\n        return raw.slice(0, limit).map((r, i) => ({\n            rank: i + 1,\n            airline: r.airline,\n            departureTime: r.departureTime,\n            departureAirport: r.departureAirport,\n            arrivalTime: r.arrivalTime,\n            arrivalAirport: r.arrivalAirport,\n            duration: r.duration,\n            stops: r.stops,\n            price: r.price,\n            currency: r.currency,\n            url: searchUrl,\n        }));\n    },\n});\n","sourceCodeStart":53,"sourceCodeEnd":88,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trip/flight.js#L53-L88","documentation":"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.","triggerScenarios":"raw from page.evaluate(buildFlightExtractJs()) is an array with length 0 for the built one-way search URL on the given date.","commonSituations":"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.","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."],"exampleFix":"// before\nconst flights = await runTripFlight({ from: 'JFK', to: 'LHR', date: '2020-01-01' });\n// after\nlet flights;\ntry {\n  flights = await runTripFlight({ from: 'JFK', to: 'LHR', date: '2026-10-01' });\n} catch (e) {\n  if (e instanceof EmptyResultError) flights = [];\n  else throw e;\n}","handlingStrategy":"try-catch","validationCode":"if (!/^[A-Z]{3}$/.test(from) || !/^[A-Z]{3}$/.test(to)) throw new Error('invalid IATA codes');\nconst d = new Date(date);\nif (isNaN(d) || d < new Date()) throw new Error('date must be a future ISO date');","typeGuard":"const isEmptyResult = (e) => e instanceof EmptyResultError || e?.name === 'EmptyResultError';","tryCatchPattern":"try {\n  const flights = await runTripFlight(args);\n} catch (e) {\n  if (isEmptyResult(e)) return [];\n  throw e;\n}","preventionTips":["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."],"tags":["empty-result","scraping","flights","trip-com"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}