jackwener/OpenCLI · error · CommandExecutionError

Trip.com car cards rendered but parser did not find required

Error message

Trip.com car cards rendered but parser did not find required price anchors

What it means

The Trip.com car-hire command's in-page extractor ran successfully but returned an empty array: car cards were present on the page, yet none of them contained the price anchors the parser requires. The CLI treats a rendered-but-unparseable grid as markup drift rather than an empty result, so it throws CommandExecutionError instead of returning [].

Source

Thrown at clis/trip/car.js:62

        const listUrl = buildCarListUrl(cityId);
        await page.goto(listUrl);
        const waitResult = await page.evaluate(WAIT_FOR_CARS_JS);
        if (waitResult === 'captcha') {
            throw new AuthRequiredError('trip.com', 'Trip.com is asking for a verification; complete it in your browser session and retry');
        }
        if (waitResult === 'empty') {
            throw new EmptyResultError('trip car', `No car rentals for city id ${cityId}`);
        }
        if (waitResult !== 'content') {
            throw new CommandExecutionError(`Trip.com car listing did not render (state=${String(waitResult)}); check the carhire city id`);
        }
        const raw = await page.evaluate(buildCarExtractJs());
        if (!Array.isArray(raw)) {
            throw new CommandExecutionError('Trip.com car DOM extraction returned malformed rows');
        }
        if (raw.length === 0) {
            throw new CommandExecutionError('Trip.com car cards rendered but parser did not find required price anchors');
        }
        return raw.slice(0, limit).map((r, i) => ({
            rank: i + 1,
            category: r.category,
            vehicle: r.vehicle,
            seats: r.seats,
            price: r.price,
            currency: r.currency,
            url: listUrl,
        }));
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the search after a short delay to rule out a partially rendered or cached page
  2. Update the Trip.com session/cookies (complete any verification in the browser session) and retry
  3. Inspect buildCarExtractJs()'s price-anchor selectors against current Trip.com car card markup and update them
  4. Check for a newer version of the CLI package that already tracks the markup change

Example fix

// before
if (raw.length === 0) {
    throw new CommandExecutionError('Trip.com car cards rendered but parser did not find required price anchors');
}
// after
if (raw.length === 0) {
    throw new CommandExecutionError('Trip.com car cards rendered but parser did not find required price anchors');
}
// Long-term: in buildCarExtractJs, add a fallback price selector
// const price = card.querySelector('.price-text') ?? card.querySelector('[data-price]');
Defensive patterns

Strategy: retry

Validate before calling

// Pre-check rendered car cards before expecting parseable rows
const cardCount = await page.evaluate(() => document.querySelectorAll('[class*=car-card], [data-car-id]').length);
if (cardCount > 0) console.warn(`${cardCount} car cards rendered; verify price anchors still exist in markup`);

Type guard

function isExtractRows(v) {
    return Array.isArray(v) && v.every(r => r && typeof r === 'object' && 'category' in r);
}

Try / catch

try {
    const cars = await runTripCarSearch(opts);
} catch (e) {
    if (e instanceof CommandExecutionError && /price anchors/.test(e.message)) {
        // markup drift: retry once, then surface a 'site markup changed' alert
    } else { throw e; }
}

Prevention

When it happens

Trigger: Running the Trip.com car search when the page renders car cards but the extractor's price-selector (the required price anchor inside each card) matches nothing, so buildCarExtractJs() filters every row out and returns [].

Common situations: Trip.com A/B-testing new card markup; a site redesign changing price element classes/data attributes; regional layouts that omit the price anchor; stale cached HTML; bot-interstitial pages that render card skeletons without prices.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/fc72f1ddcc2dc377. Report an issue: GitHub.