{"record":{"id":"881179ccc6f9cc8e","repo":"jackwener/OpenCLI","slug":"unexpected-response-while-loading-xueqiu-comments-881179","errorCode":null,"errorMessage":"Unexpected response while loading xueqiu comments for ${options.symbol}","messagePattern":"Unexpected response while loading xueqiu comments for (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xueqiu/comments.js","lineNumber":266,"sourceCode":"        const response = await options.fetchPage(requestNumber, options.pageSize);\n        const classified = classifyXueqiuCommentsResponse(response);\n        if (requestNumber === 1 && classified.kind !== 'unknown') {\n            throwFirstPageFailure(classified.kind, options.symbol);\n        }\n        else if (classified.kind === 'empty') {\n            break;\n        }\n        else if (classified.kind !== 'unknown') {\n            warn(buildPaginationStopMessage(requestNumber, rows.length, options.limit, describeFailureKind(classified.kind)));\n            break;\n        }\n        const rawItems = getCommentItems(response.json);\n        const pageRows = rawItems\n            .map(item => normalizeCommentItem(item))\n            .filter(row => row.id);\n        if (pageRows.length === 0) {\n            if (requestNumber === 1) {\n                throw new CommandExecutionError(`Unexpected response while loading xueqiu comments for ${options.symbol}`, 'Run the command again with --verbose to inspect the raw site response.');\n            }\n            if (classified.kind === 'unknown') {\n                warn(buildPaginationStopMessage(requestNumber, rows.length, options.limit, describeFailureKind(classified.kind)));\n            }\n            break;\n        }\n        let advanced = false;\n        for (const row of pageRows) {\n            if (seenIds.has(row.id))\n                continue;\n            seenIds.add(row.id);\n            rows.push(row);\n            advanced = true;\n        }\n        if (rows.length >= options.limit) {\n            return rows.slice(0, options.limit);\n        }\n        if (rawItems.length < options.pageSize) {","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xueqiu/comments.js#L248-L284","documentation":"In collectCommentRows, if the first page classifies as 'unknown' but yields zero normalized rows (no items with an id), the command throws CommandExecutionError 'Unexpected response while loading xueqiu comments for <symbol>'. This differs from 4948: the classifier could not categorize the response AND item extraction found nothing usable, so the command fails hard rather than returning empty.","triggerScenarios":"First fetchPage call returns a response whose classifyXueqiuCommentsResponse result is 'unknown' (e.g. status 0 from an in-page fetch exception, or JSON whose list contains only items without ids), so getCommentItems/normalizeCommentItem produce zero rows with requestNumber === 1.","commonSituations":"Network failure inside the browser (status 0 with the error message as textSnippet); a page of items that all lack an `id` field after a site schema change; JSON present but list items are strings/null instead of objects.","solutions":["Re-run with --verbose to see the raw first response (a status 0 means the in-page fetch threw — check connectivity/proxy)","Re-login to xueqiu and retry to rule out session-related filtering","Try a different liquid symbol to distinguish symbol-specific from systemic issues","If items consistently lack ids, the site schema changed — check for a library update"],"exampleFix":"// before (crashing the whole command on a transient first-page failure)\nconst rows = await collectCommentRows(opts); // throws\n// after (retry once at the caller)\nlet rows;\ntry { rows = await collectCommentRows(opts); }\ncatch (e) { rows = await collectCommentRows(opts); }","handlingStrategy":"retry","validationCode":"const cookies = await page.getCookies({ url: 'https://xueqiu.com' });\nif (!cookies.some(c => c.name === 'xq_a_token' && c.value)) {\n  throw new Error('Login to xueqiu before fetching comments');\n}\n// also confirm network reachability to xueqiu.com from the browser","typeGuard":null,"tryCatchPattern":"try {\n  const rows = await collectCommentRows(opts);\n} catch (e) {\n  if (/Unexpected response while loading xueqiu comments/.test(e.message)) {\n    await new Promise(r => setTimeout(r, 3000));\n    return collectCommentRows(opts); // single retry for transient first-page failures\n  }\n  throw e;\n}","preventionTips":["Ensure stable network/proxy access to xueqiu.com from the automation browser","Login and verify before fetching so sessions are healthy","Use --verbose to distinguish status-0 fetch failures from schema changes","Retry once on first-page failures; persistent failures need raw-response inspection"],"tags":["unexpected-response","xueqiu","empty-page","network"],"backgroundTag":"unexpected-response-schema","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}