jackwener/OpenCLI · error · CommandExecutionError
Trip.com package search failed with status ${response.status
Error message
Trip.com package search failed with status ${response.status} What it means
fetchPackageSearch checks response.ok after the POST resolves; a non-2xx HTTP status (403, 429, 500, 502, 503, etc.) is thrown as CommandExecutionError with 'Trip.com package search failed with status N'. The network call succeeded but Trip.com's server rejected or failed the request.
Source
Thrown at clis/trip/utils.js:958
flightcriteria: {
osource: 1, triptype: 1, fmap: 19, sflag: 0, rtype: 2,
seglist: [{ segno: 1, ddate: depart, sgrade: 4, dcode, acode }],
pinfo: { adults, children: 0, babys: 0 },
},
hotelcriteria: { chin: depart, chout: ret, hcityid, rnum: 1 },
};
let response;
try {
response = await fetch(PACKAGE_SEARCH_ENDPOINT, {
method: 'POST',
headers: { 'content-type': 'application/json', currency: 'USD' },
body: JSON.stringify(body),
});
} catch (err) {
throw new CommandExecutionError(`Trip.com package search fetch failed: ${err instanceof Error ? err.message : String(err)}`);
}
if (!response.ok) {
throw new CommandExecutionError(`Trip.com package search failed with status ${response.status}`);
}
let payload;
try {
payload = await response.json();
} catch (err) {
throw new CommandExecutionError(`Trip.com package search returned invalid JSON: ${err instanceof Error ? err.message : String(err)}`);
}
if (!Array.isArray(payload?.grouplist)) {
throw new CommandExecutionError('Trip.com package search returned malformed payload: missing grouplist array');
}
return payload.grouplist;
}
/**
* Project a package flight group into the stable adapter column shape. A group's
* `flightlist` is the itinerary legs (one for a nonstop), so the route summary
* reads the departure off the first leg and the arrival off the last, with the
* leg count minus one as the stop count. `price` is the per-person packageView on GitHub (pinned to 49907e53dc)
Solutions
- Capture the status code and, if possible, the response body to identify the cause
- Add throttling/delay between package search calls to avoid 429
- Implement retry with exponential backoff for 5xx and 429 responses
- Validate the POST body/headers match the current API contract; update the client if Trip.com changed it
Example fix
// before
await Promise.all(cities.map(c => search(c))) // bursts -> 429
// after
for (const c of cities) { await search(c); await sleep(2000) } Defensive patterns
Strategy: retry
Validate before calling
// sanity-check required params before POSTing
if (!fromCity || !toCity || !departDate) throw new Error('from, to and departDate are required for package search'); Type guard
null
Try / catch
async function packagesWithRetry(params, retries = 3) {
for (let i = 0; i < retries; i++) {
try { return await searchPackages(params); }
catch (e) {
const m = /failed with status (\d+)/.exec(e.message);
if (m && (m[1] === '429' || m[1].startsWith('5')) && i < retries - 1) { await sleep(1500 * 2 ** i); continue; }
throw e;
}
}
} Prevention
- Space out package search calls to stay under rate limits
- Retry only 429/5xx; surface 4xx immediately for parameter fixes
- Keep the request body/headers aligned with the current Trip.com contract
- Alert on repeated 403 — usually anti-bot/WAF blocking
When it happens
Trigger: Posting package search requests too rapidly (429); Trip.com WAF blocking the request (403); wrong endpoint or params causing 404/400; Trip.com server errors (5xx) during outage windows; missing/invalid headers (currency, content-type) triggering rejection.
Common situations: Batch scripts issuing many package searches without throttling; expired anti-bot/session state; API path or payload schema drift after a Trip.com update; regional outages or maintenance.
Related errors
- Trip.com poiSearch failed with status ${response.status}
- Douyin API error ${code} at ${method} ${url}: ${msg}
- HTTP_ERROR
- hf datasets failed: HTTP ${resp.status}
- hf models failed: HTTP ${resp.status}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/ab8177b855c23d0b.
Report an issue: GitHub.