{"record":{"id":"0406a9b6447b9c92","repo":"jackwener/OpenCLI","slug":"unexpected-response-while-loading-xueqiu-comments","errorCode":null,"errorMessage":"Unexpected response while loading xueqiu comments for ${symbol}","messagePattern":"Unexpected response while loading xueqiu comments for (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xueqiu/comments.js","lineNumber":53,"sourceCode":"        return String(value);\n    return '';\n}\nfunction buildPaginationStopMessage(requestNumber, collected, target, reason) {\n    return `xueqiu comments pagination stopped after request ${requestNumber}, `\n        + `collected ${collected}/${target} items, `\n        + `reason: ${reason}`;\n}\nfunction throwFirstPageFailure(kind, symbol) {\n    if (kind === 'auth' || kind === 'anti-bot') {\n        throw new AuthRequiredError('xueqiu.com', 'Stock discussions require login or challenge clearance');\n    }\n    if (kind === 'argument') {\n        throw new ArgumentError(`xueqiu comments received an invalid symbol: ${symbol}`);\n    }\n    if (kind === 'empty') {\n        throw new EmptyResultError(`xueqiu/comments ${symbol}`, `No discussion data found for ${symbol}`);\n    }\n    throw new CommandExecutionError(`Unexpected response while loading xueqiu comments for ${symbol}`, 'Run the command again with --verbose to inspect the raw site response.');\n}\n/**\n * Extract the raw item list from one classified JSON payload.\n *\n * @param json Raw parsed JSON payload from browser fetch.\n * @returns Discussion items when the response shape is usable.\n */\nexport function getCommentItems(json) {\n    if (!isRecord(json))\n        return [];\n    const list = getCommentList(json) ?? [];\n    return list.filter((item) => !!item && typeof item === 'object');\n}\n/**\n * Classify one raw browser response before command-level error handling.\n *\n * @param response Structured browser response payload.\n * @returns Tagged result describing the response class.","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xueqiu/comments.js#L35-L71","documentation":"Catch-all branch of throwFirstPageFailure: when the first comments page is classified 'incompatible' (JSON content type but no recognizable list shape) it falls through to CommandExecutionError 'Unexpected response while loading xueqiu comments for <symbol>' with the hint to re-run with --verbose. It means xueqiu answered with JSON that does not match the expected envelope, i.e. an API shape change or an unrecognized error payload.","triggerScenarios":"First request to the search/status endpoint returns application/json that parses, but contains neither json.list nor json.data.list, and matches none of the auth/anti-bot/argument/empty text patterns.","commonSituations":"Xueqiu changing the /query/v1/symbol/search/status response schema; a new error envelope format the classifier does not know; CDN or proxy returning a JSON error page from a middlebox.","solutions":["Re-run with --verbose to inspect the raw site response and identify the new shape","Re-login and retry — an unusual session state can produce unusual envelopes","Retry later in case of a transient site-side change or A/B test","If persistent, check for a library update; the response classifier likely needs the new schema"],"exampleFix":"// before\nopencli xueqiu comments AAPL\n// after (diagnose)\nopencli xueqiu comments AAPL --verbose  # inspect raw JSON body","handlingStrategy":"retry","validationCode":null,"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    console.error('Unknown JSON shape — re-run with --verbose to inspect raw response');\n  } else throw e;\n}","preventionTips":["Diagnose with --verbose on first occurrence to capture the raw payload","Keep the library updated — classifier schemas must track xueqiu changes","Rule out middleboxes (corporate proxies) returning JSON error pages","Retry after re-login to rule out session-dependent response variants"],"tags":["schema-change","xueqiu","unexpected-response"],"backgroundTag":"unexpected-response-schema","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}