{"record":{"id":"a0a262ebde7c3533","repo":"jackwener/OpenCLI","slug":"uisdc-news-page-returned-an-unreadable-payload","errorCode":null,"errorMessage":"UISDC news page returned an unreadable payload","messagePattern":"UISDC news page returned an unreadable payload","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/uisdc/news.js","lineNumber":54,"sourceCode":"          };\n        }\n        const rows = cards.map((el, index) => {\n          const anchor = el.querySelector('a[href]');\n          return {\n            rank: index + 1,\n            title: el.querySelector('.dubao-title')?.textContent || '',\n            summary: el.querySelector('.dubao-content')?.textContent || '',\n            url: anchor ? new URL(anchor.getAttribute('href'), location.href).href : '',\n          };\n        });\n        return { ok: true, rows };\n      })()\n    `;\n}\n\nfunction toRows(payload, limit) {\n    if (!payload || typeof payload !== 'object') {\n        throw new CommandExecutionError('UISDC news page returned an unreadable payload');\n    }\n    if (!payload.ok) {\n        const reason = typeof payload.reason === 'string' && payload.reason.trim() ? payload.reason.trim() : 'selector-drift';\n        throw new CommandExecutionError(\n            `UISDC news selector drift: ${reason}`,\n            payload.title ? `Page title: ${payload.title}` : undefined,\n        );\n    }\n    const rows = (Array.isArray(payload.rows) ? payload.rows : [])\n        .map((row, index) => ({\n            rank: index + 1,\n            title: normalizeText(row.title),\n            summary: normalizeText(row.summary),\n            url: normalizeText(row.url),\n        }))\n        .filter((row) => row.title && row.url);\n    if (rows.length === 0) {\n        throw new EmptyResultError('uisdc news', 'UISDC news page loaded, but no news rows with title and URL were extracted.');","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/uisdc/news.js#L36-L72","documentation":"toRows validates the payload returned by the in-page extraction script. If the payload is null, undefined, or not an object, it throws CommandExecutionError 'UISDC news page returned an unreadable payload', meaning page.evaluate did not return the expected structured result.","triggerScenarios":"page.evaluate(buildExtractUisdcNewsJs()) resolving to null/undefined or a non-object (e.g. a serialized string), or the injected script returning nothing after navigation problems.","commonSituations":"Page redirected to an error/login/captcha page so the extractor returned undefined; automation framework serialization quirk; SPA rewrote the DOM before the script's guarded return.","solutions":["Retry the command; transient redirects or slow loads often resolve on a second run","Check that UISDC_NEWS_URL loads normally in a browser (not blocked or redirected)","Inspect the page's anti-bot behavior; use a visible/headed browser if the site blocks automation","File/inspect buildExtractUisdcNewsJs to ensure it always returns an object"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const payload = await page.evaluate(js).catch(() => null);\nif (!payload || typeof payload !== 'object') throw new Error('extraction returned no object');","typeGuard":"function isReadablePayload(p) { return !!p && typeof p === 'object' && !Array.isArray(p); }","tryCatchPattern":"try { const rows = await loadUisdcNews(page, args); } catch (e) { if (/unreadable payload/.test(e.message)) { await retryWithFreshPage(); } else throw e; }","preventionTips":["Retry once with a freshly navigated page before giving up","Confirm the URL isn't redirecting to a login/captcha wall","Log page.url() and title on failure for diagnosis","Keep the extraction script returning an explicit object in all paths"],"tags":["scraping","payload","command-execution-error"],"backgroundTag":"unreadable-scrape-payload","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}