{"record":{"id":"9b9a638f024525b7","repo":"jackwener/OpenCLI","slug":"trip-com-hotel-detail-page-did-not-expose-ssr-hote","errorCode":null,"errorMessage":"Trip.com hotel detail page did not expose SSR hotel data (state=${String(waitResult)})","messagePattern":"Trip\\.com hotel detail page did not expose SSR hotel data \\(state=(.+?)\\)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/trip/hotel.js","lineNumber":43,"sourceCode":"        { name: 'id', required: true, positional: true, help: 'Numeric Trip.com hotel id (discover via the hotels list; e.g. 715233)' },\n    ],\n    columns: [\n        'hotelId', 'name', 'enName',\n        'star', 'score', 'scoreLabel', 'reviewCount', 'ratingBreakdown',\n        'facilities', 'checkInOut',\n        'cityName', 'address', 'lat', 'lon',\n        'url',\n    ],\n    func: async (page, kwargs) => {\n        const hotelId = parseHotelId('id', kwargs.id);\n        const url = buildHotelDetailUrl(hotelId);\n        await page.goto(url);\n        const waitResult = await page.evaluate(WAIT_FOR_HOTEL_DETAIL_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 hotel detail page did not expose SSR hotel data (state=${String(waitResult)})`);\n        }\n        const detail = await page.evaluate(buildHotelDetailExtractJs());\n        if (!detail || typeof detail !== 'object') {\n            throw new CommandExecutionError('Trip.com hotel detail SSR extraction returned malformed data');\n        }\n        if (!detail.hotelId || !detail.name) {\n            throw new EmptyResultError('trip hotel', `No detail exposed for hotel id ${hotelId}`);\n        }\n        return [{ ...detail, url }];\n    },\n});\n","sourceCodeStart":25,"sourceCodeEnd":55,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trip/hotel.js#L25-L55","documentation":"This CommandExecutionError fires when the hotel detail page loaded but WAIT_FOR_HOTEL_DETAIL_JS returned a state other than 'content' or 'captcha' — the page never exposed Trip.com's SSR hotel data blob. It signals a page-structure or load problem rather than an auth problem.","triggerScenarios":"The detail page rendered a slow/error/redirect state so the SSR data node never appeared within the wait script's tolerance: slow network, changed Trip.com markup, or a soft error page for an invalid hotelId.","commonSituations":"Trip.com front-end update renaming the SSR data variable, timeouts on slow connections, deleted/unavailable hotel ids redirecting to a generic page, or intermittent CDN errors.","solutions":["Retry the request — transient slow loads often resolve on a second attempt","Verify the hotelId is valid by checking the hotel URL opens with data in a real browser","Update the library / WAIT_FOR_HOTEL_DETAIL_JS selectors if Trip.com changed its SSR markup","Increase page wait/timeout budget for slow networks"],"exampleFix":"// before\nawait tripHotelDetail({ id: '123456' }); // intermittent state=timeout\n// after\nawait withRetry(() => tripHotelDetail({ id: '123456' }), { attempts: 3, backoffMs: 1000 });","handlingStrategy":"retry","validationCode":"const url = buildHotelDetailUrl(hotelId);\nif (!Number.isFinite(Number(hotelId)) || Number(hotelId) <= 0) {\n  throw new Error(`invalid hotel id: ${hotelId}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await tripHotelDetail({ id });\n} catch (e) {\n  if (e instanceof CommandExecutionError && e.message.includes('SSR hotel data')) {\n    await sleep(1500);\n    return await tripHotelDetail({ id }); // one retry for transient slow loads\n  }\n  throw e;\n}","preventionTips":["Retry once with backoff before failing — slow renders are common","Validate hotel ids against a fresh search rather than cached old listings","Keep the library updated for Trip.com markup changes","Increase page timeouts on slow networks"],"tags":["scraping","ssr","dom","trip-com","page-structure"],"backgroundTag":"dom-selector-mismatch","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}