{"record":{"id":"1f8f31dd98de89fb","repo":"jackwener/OpenCLI","slug":"booking-com-extractor-returned-an-invalid-status","errorCode":null,"errorMessage":"Booking.com extractor returned an invalid status","messagePattern":"Booking\\.com extractor returned an invalid status","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/booking/search.js","lineNumber":288,"sourceCode":"    let raw;\n    try {\n      raw = await page.evaluate(EXTRACTOR);\n    } catch (err) {\n      throw new CommandExecutionError(`Failed to extract Booking.com cards: ${err?.message || err}`);\n    }\n\n    if (raw && typeof raw === 'object' && raw.data && raw.session) {\n      raw = raw.data;\n    }\n    if (!raw || typeof raw !== 'object') {\n      throw new CommandExecutionError('Booking.com page returned no extractable data');\n    }\n    if (raw.blocked) {\n      throw new CommandExecutionError('Booking.com served a verification / captcha page; retry later or change profile');\n    }\n\n    if (raw.ok !== true) {\n      throw new CommandExecutionError('Booking.com extractor returned an invalid status');\n    }\n    if (!Array.isArray(raw.items)) {\n      throw new CommandExecutionError('Booking.com extractor returned malformed items');\n    }\n\n    const items = raw.items;\n    if (items.length === 0) {\n      const totalText = String(raw.totalText || '').trim();\n      if (hasPositiveResultCount(totalText)) {\n        throw new CommandExecutionError(\n          `Booking.com page declared results but no property cards were parsed: ${totalText}`,\n        );\n      }\n      throw new EmptyResultError(\n        `booking search ${JSON.stringify(destination)}`,\n        totalText\n          ? `No hotels rendered (${totalText}). Try a broader destination, different dates, or check the URL in a browser.`\n          : 'No hotels rendered. Try a broader destination, different dates, or check the URL in a browser.',","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/booking/search.js#L270-L306","documentation":"This CommandExecutionError is thrown when the extractor's result is an object but its ok flag is not exactly true (raw.ok !== true). The library treats ok as a contract marker from the extractor script; anything else means the extractor ran but reported an abnormal/unknown status, so the result cannot be trusted.","triggerScenarios":"The in-page EXTRACTOR returned an object whose ok property is false, missing, or not the boolean true — e.g. partial failure inside the extractor, an enveloped/mismatched response shape after unwrapping {data, session}, or an extractor/script version mismatch.","commonSituations":"Stale cached extractor script on a page whose structure changed; a custom or patched EXTRACTOR passed by the caller; the data/session unwrap picked the wrong object; extractor caught an internal error and returned {ok:false, reason:...}.","solutions":["Log/inspect the full raw object returned by page.evaluate to see the actual shape and any reason field.","Retry the search — a transient in-page failure can produce ok:false.","Update the library so EXTRACTOR matches the current Booking.com DOM.","If you supply a custom extractor, ensure it returns {ok:true, items:[...]} on success.","Check that the {data, session} unwrap logic matches your runtime's response envelope."],"exampleFix":"// before\nif (raw.ok !== true) throw new Error('invalid status');\n// after\nconsole.error('extractor status:', raw.ok, raw);\nif (raw.ok !== true) throw new Error('invalid status: ' + JSON.stringify(raw).slice(0, 200));","handlingStrategy":"fallback","validationCode":"// pre-check custom extractor contract if you inject one\nif (typeof customExtractor === 'function') {\n  const probe = customExtractor.toString();\n  if (!/ok/.test(probe)) console.warn('extractor may not honor the {ok:true} contract');\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await booking.search(params);\n} catch (e) {\n  if (/invalid status/.test(e.message)) {\n    console.error('extractor status payload unavailable; retrying once');\n    return booking.search(params);\n  }\n  throw e;\n}","preventionTips":["Keep the library version matched to current Booking.com DOM.","Do not patch EXTRACTOR casually; keep its {ok:true, items:[]} contract.","Log the raw evaluate() result when debugging extraction issues.","Treat ok:false as retryable, not fatal data corruption."],"tags":["scraping","contract-violation","browser-automation"],"backgroundTag":"schema-validation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}