jackwener/OpenCLI · error · CommandExecutionError
Ctrip flight API response exceeded the browser capture limit
Error message
Ctrip flight API response exceeded the browser capture limit
What it means
This CommandExecutionError is thrown when the captured batchSearch response body was truncated (responseBodyTruncated === true), i.e. the payload exceeded the browser/CDP capture size limit. The library cannot parse a partial JSON body safely, so it fails fast rather than returning incomplete flight results. It is a capture-infrastructure limitation, not a Ctrip API failure.
Source
Thrown at clis/ctrip/flight.js:75
function parseBatchSearchCaptures(entries) {
if (!Array.isArray(entries)) {
throw new CommandExecutionError('Ctrip flight network capture returned malformed entries');
}
const captured = entries.filter((entry) => String(entry?.url || '').includes(CAPTURE_PATTERN));
if (captured.length === 0) return null;
const byId = new Map();
let finished = false;
for (const entry of captured) {
const status = Number(entry?.responseStatus || 0);
if (status === 401 || status === 403) {
throw new AuthRequiredError('flights.ctrip.com', `Ctrip flight API returned HTTP ${status}; complete any verification in the browser and retry`);
}
if (status !== 200) {
throw new CommandExecutionError(`Ctrip flight API returned HTTP ${status || 'unknown'}`);
}
if (entry?.responseBodyTruncated === true) {
throw new CommandExecutionError('Ctrip flight API response exceeded the browser capture limit');
}
if (typeof entry?.responsePreview !== 'string') {
throw new CommandExecutionError('Ctrip flight API response body was unavailable');
}
let payload;
try {
payload = JSON.parse(entry.responsePreview);
}
catch {
throw new CommandExecutionError('Ctrip flight API returned invalid JSON');
}
if (payload?.status !== 0) {
throw new CommandExecutionError(`Ctrip flight API failed (status=${String(payload?.status)}): ${cleanString(payload?.msg) || 'unknown error'}`);
}
const itineraries = payload?.data?.flightItineraryList;
if (!Array.isArray(itineraries) || typeof payload?.data?.context?.finished !== 'boolean') {
throw new CommandExecutionError('Ctrip flight API returned a malformed batchSearch payload');
}View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run with a smaller --limit (e.g. 20 or fewer) so the response payload stays under the capture limit.
- Narrow the search (specific cabin/airline via the page UI or the round-trip command) to reduce result size.
- Increase the browser capture/CDP response-body limit in the host tooling if you control it.
- If truncation persists, split the query into smaller time windows or routes.
Example fix
// before
await cli.itineraries({ from: 'PEK', to: 'SHA', date: '2026-10-01', limit: 50 });
// after: keep payload under capture limit
await cli.itineraries({ from: 'PEK', to: 'SHA', date: '2026-10-01', limit: 20 }); Defensive patterns
Strategy: validation
Validate before calling
// check requested size before invoking
if (Number(args.limit) > 20) {
console.warn('Large limits can exceed the browser capture limit; prefer limit <= 20 on dense routes.');
} Try / catch
try {
return await cli.itineraries({ ...args, limit: 20 });
} catch (err) {
if (/capture limit/i.test(err.message || '')) {
return cli.itineraries({ ...args, limit: Math.max(1, Math.floor((args.limit || 20) / 2)) });
}
throw err;
} Prevention
- Keep --limit modest (<=20) on busy trunk routes and holiday dates.
- Narrow searches (specific dates/routes) to shrink payloads.
- If you control the tooling, raise the CDP response-body size limit.
- Treat this error as 'query too big' and automatically halve the limit on retry.
When it happens
Trigger: A batchSearch response whose JSON body is larger than the CDP response-body capture limit — typically very popular routes with huge itinerary lists, wide multi-passenger searches, or limit set to the maximum (50).
Common situations: Searching dense domestic trunk routes (e.g. PEK->SHA) around holidays with limit=50; capture buffer configured too small in the CDP layer; Ctrip returning an unusually large payload (many fare families/bundles).
Related errors
- 1688 ${action} navigation lost the current browser target
- amazon ${action} navigation lost the current browser target
- Cannot connect to Antigravity at ${endpoint}. 1. Make sure
- 字幕获取失败: ${err?.message || err}
- 字幕获取结果对象不符合预期格式
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/347ca1cdf02c5550.
Report an issue: GitHub.