{"record":{"id":"c74402dfa437f3dc","repo":"jackwener/OpenCLI","slug":"aibase-daily-page-returned-an-unreadable-payload","errorCode":null,"errorMessage":"AIbase daily page returned an unreadable payload","messagePattern":"AIbase daily page returned an unreadable payload","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/aibase/news.js","lineNumber":60,"sourceCode":"        const rows = [];\n        for (const anchor of anchors) {\n          const url = new URL(anchor.getAttribute('href'), location.href).href;\n          if (seen.has(url)) continue;\n          seen.add(url);\n          rows.push({\n            rank: rows.length + 1,\n            title: anchor.innerText || anchor.textContent || '',\n            url,\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('AIbase daily 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            `AIbase daily 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            url: normalizeText(row.url),\n        }))\n        .filter((row) => row.title && row.url);\n    if (rows.length === 0) {\n        throw new EmptyResultError('aibase news', 'AIbase daily page loaded, but no article rows with title and URL were extracted.');\n    }","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/aibase/news.js#L42-L78","documentation":"toRows throws this CommandExecutionError when the payload returned from the injected page.evaluate extraction script is null, undefined, or not an object — i.e. the AIbase daily page yielded nothing usable to interpret. It is distinct from selector drift (which produces a structured {ok:false} payload); here the script returned nothing structured at all.","triggerScenarios":"page.evaluate resolves to null/undefined or a primitive — e.g. the script failed to return, the page navigated/reloaded during evaluation, or the browser wrapper returned a non-object (or an ununwrap-able envelope whose data is null).","commonSituations":"Page redirected to a captcha/login/consent interstitial so the script context produced nothing; browser crashed mid-evaluation and the wrapper returned undefined; network served an error page that short-circuits the script; running against a cached/stale session.","solutions":["Re-run the command — often transient (redirect, slow load).","Run the site's login command first if AIbase now gates the daily page, so evaluation happens on the real page.","Increase settle time / retry to let the page finish loading before extraction.","Inspect the page manually (or in foreground mode) to see what the daily URL actually renders now; update the extraction script if the page changed fundamentally."],"exampleFix":"null","handlingStrategy":"retry","validationCode":"// ensure the page is reachable and not an interstitial\nconst res = await fetch('https://www.aibase.com/zh/daily', { redirect: 'follow' });\nconst html = await res.text();\nif (!html.includes('daily')) console.warn('Daily page may be an interstitial or redirected');","typeGuard":"function isUsablePayload(p) {\n  return p !== null && typeof p === 'object';\n}","tryCatchPattern":"try {\n  await runCommand(['aibase', 'news']);\n} catch (e) {\n  if (e instanceof CommandExecutionError && e.message.includes('unreadable payload')) {\n    console.error('Extraction returned nothing; retrying after backoff');\n  } else throw e;\n}","preventionTips":["Retry transient failures before debugging","Complete site login if the daily page becomes gated","Inspect what the daily URL renders when it persistently fails","Keep the browser session fresh"],"tags":["browser-scraping","payload-shape","cli"],"backgroundTag":"unexpected-payload-shape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}