{"record":{"id":"7d3e6698e36aab1c","repo":"jackwener/OpenCLI","slug":"ctrip-flight-round","errorCode":null,"errorMessage":"ctrip flight-round","messagePattern":"ctrip flight-round","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/ctrip/flight-round.js","lineNumber":98,"sourceCode":"            `?depdate=${depart}_${ret}&cabin=Y_S_C_F&adult=1&child=0&infant=0`;\n        await page.goto(searchUrl);\n        const waitResult = await page.evaluate(WAIT_FOR_FLIGHTS_ROUND_JS);\n        if (waitResult === 'captcha') {\n            throw new AuthRequiredError('flights.ctrip.com', 'Ctrip is asking for a captcha; complete it in your browser session and retry');\n        }\n        if (waitResult !== 'content') {\n            throw new CommandExecutionError(`Ctrip round-trip flight page did not render flight cards (state=${String(waitResult)})`);\n        }\n        const renderedCardCount = await page.evaluate(buildScrollUntilJs(ROUND_CARD_SELECTOR, limit));\n        const raw = await page.evaluate(buildFlightExtractJs(ROUND_CARD_SELECTOR, false));\n        if (!Array.isArray(raw)) {\n            throw new CommandExecutionError('Ctrip round-trip flight DOM extraction returned malformed rows');\n        }\n        if (raw.length === 0) {\n            if (Number(renderedCardCount) > 0) {\n                throw new CommandExecutionError('Ctrip round-trip flight cards rendered but parser did not find required flight anchors');\n            }\n            throw new EmptyResultError('ctrip flight-round', `No round-trip flights for ${fromCode}→${toCode} on ${depart} / ${ret}`);\n        }\n        const completeRows = raw\n            .filter((r) => r.departureTime && r.departureAirport && r.arrivalTime && r.arrivalAirport && r.airline)\n            .slice(0, limit)\n            .map((r, i) => ({\n                rank: i + 1,\n                airline: r.airline,\n                flightNo: r.flightNo,\n                aircraft: r.aircraft,\n                departureTime: r.departureTime,\n                departureAirport: r.departureAirport,\n                arrivalTime: r.arrivalTime,\n                arrivalAirport: r.arrivalAirport,\n                terminal: r.terminal,\n                price: r.price,\n                currency: r.currency,\n                cabin: r.cabin,\n                url: searchUrl,","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/ctrip/flight-round.js#L80-L116","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst rows = await cli(['flight-round', '--from', a, '--to', b, '--depart', d, '--return', r]); // crash on empty\n// after\ntry { const rows = await cli([...]); if (!rows.length) showNoFlightsMessage(); }\ncatch (e) { if (e instanceof EmptyResultError) showNoFlightsMessage(); else throw e; }","handlingStrategy":"try-catch","validationCode":"const dep = new Date(departDate); const now = new Date();\nif (isNaN(dep) || dep < new Date(now.toDateString())) throw new Error('depart date must be a valid future date');","typeGuard":"function isEmptyResultError(e) { return e && (e.code === 'EMPTY_RESULT' || e instanceof EmptyResultError); }","tryCatchPattern":"try { const rows = await cli(['flight-round','--from',a,'--to',b,'--depart',d,'--return',r]); return rows; }\ncatch (e) { if (isEmptyResultError(e)) return []; throw e; }","preventionTips":["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."],"tags":["empty-result","scraping","ctrip","flights"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}