{"record":{"id":"5acdd3e3a3974d41","repo":"jackwener/OpenCLI","slug":"no-round-trip-flights-for-fromcode-to-tocode","errorCode":null,"errorMessage":"No round-trip flights for ${fromCode} to ${toCode} on ${depart} .. ${ret}","messagePattern":"No round-trip flights for (.+?) to (.+?) on (.+?) \\.\\. (.+?)","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/trip/flight-round.js","lineNumber":76,"sourceCode":"        const searchUrl = buildFlightRoundSearchUrl(fromCode, toCode, depart, ret);\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-round', `No round-trip flights for ${fromCode} to ${toCode} on ${depart} .. ${ret}`);\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":58,"sourceCodeEnd":93,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trip/flight-round.js#L58-L93","documentation":"This EmptyResultError from clis/trip/flight-round.js is thrown after the Trip.com round-trip flight page was successfully scraped but the DOM extraction returned zero rows. The command ran correctly end-to-end; the site simply had no matching round-trip flights for the given origin/destination and date pair. It is a structured 'no results' signal, not a scraping or auth failure, so callers can treat it as a normal empty result.","triggerScenarios":"Running the flight-round command with --from/--to/--depart/--ret where Trip.com's search page renders zero flight cards, e.g. after page.evaluate(buildFlightExtractJs()) returns an empty array and raw.length === 0.","commonSituations":"Searching an obscure or seasonal route with no service on the chosen dates; requesting depart/ret dates in the past or beyond the booking window; dates formatted so the URL points at an unlikely day; a very short same-day round trip where Trip.com shows nothing; transient site-side empty renders on slow loads.","solutions":["Verify the route actually has round-trip service on those dates by checking Trip.com in a browser with the same URL.","Confirm --depart and --ret are future dates within Trip.com's booking window and correctly formatted (ISO).","Adjust dates or route (nearby airports) and retry.","Catch EmptyResultError in the caller and handle it as 'no flights' rather than a crash."],"exampleFix":"// before\nconst rows = await runTripFlightRound({ from: 'XYZ', to: 'ABC', depart: '2020-01-01', ret: '2020-01-02' });\n// after\ntry {\n  const rows = await runTripFlightRound({ from: 'SFO', to: 'LAX', depart: '2026-09-10', ret: '2026-09-15' });\n} catch (e) {\n  if (e instanceof EmptyResultError) return [];\n  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 dep = new Date(depart), ret = new Date(ret);\nif (isNaN(dep) || isNaN(ret) || dep < new Date() || ret < dep) throw new Error('invalid round-trip dates');","typeGuard":"const isEmptyResult = (e) => e instanceof EmptyResultError || e?.name === 'EmptyResultError';","tryCatchPattern":"try {\n  const flights = await runTripFlightRound(args);\n} catch (e) {\n  if (isEmptyResult(e)) return [];\n  throw e;\n}","preventionTips":["Validate IATA codes and ISO dates before invoking.","Pick future dates within the booking window.","Catch EmptyResultError wherever you iterate candidate routes so one empty route does not abort a batch.","Spot-check unusual routes on Trip.com in a browser first."],"tags":["empty-result","scraping","trip-com","flights"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}