{"record":{"id":"3add0622fef4c587","repo":"jackwener/OpenCLI","slug":"xueqiu-comments-received-an-invalid-symbol-symb","errorCode":null,"errorMessage":"xueqiu comments received an invalid symbol: ${symbol}","messagePattern":"xueqiu comments received an invalid symbol: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/xueqiu/comments.js","lineNumber":48,"sourceCode":"}\nfunction normalizeIdentifier(value) {\n    if (typeof value === 'string')\n        return value.trim();\n    if (typeof value === 'number' && Number.isFinite(value))\n        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}","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xueqiu/comments.js#L30-L66","documentation":"When the first comments page is classified 'argument' — the JSON envelope text matches /invalid symbol|invalid code|bad symbol/ — throwFirstPageFailure throws ArgumentError with the offending symbol. The site itself rejected the ticker as invalid, even though it passed the CLI's local pattern check.","triggerScenarios":"`xueqiu comments <symbol>` where symbol matches the local regex but xueqiu's search/status API responds with an 'invalid symbol/code' error envelope — e.g. delisted tickers, wrong-market prefixes (SZ000001 vs SH600519 style mistakes), or US tickers xueqiu does not list.","commonSituations":"Typos like SH60051 (5 digits instead of 6); using an exchange prefix xueqiu does not recognize; querying a delisted or renamed stock; confusing Hong Kong 5-digit codes with A-share codes.","solutions":["Verify the symbol on xueqiu.com's website search and copy the exact ticker it uses","Check prefix correctness: SH/SZ for A-shares, plain digits for HK (e.g. 00700), plain letters for US (e.g. AAPL)","Try a well-known symbol like AAPL or SH600519 to confirm your session works and isolate the issue to the symbol","If the symbol is valid on the site but still rejected, check for library updates — the API may have changed"],"exampleFix":"// before\nopencli xueqiu comments SH60051\n// after\nopencli xueqiu comments SH600519","handlingStrategy":"validation","validationCode":"const SYMBOL_RE = /^(?:[A-Z]{2}\\d{5,6}|\\d{4,6}|[A-Z]{1,5}(?:[.-][A-Z]{1,2})?)$/;\nconst symbol = String(raw).trim().toUpperCase();\nif (!SYMBOL_RE.test(symbol)) throw new Error(`Invalid symbol format: ${symbol}`);\nif (/^S[HZ]\\d{5}$/.test(symbol)) throw new Error('A-share codes need 6 digits, e.g. SH600519');","typeGuard":null,"tryCatchPattern":"try {\n  const rows = await fetchComments(symbol);\n} catch (e) {\n  if (/invalid symbol/.test(e.message)) {\n    console.error(`Symbol ${symbol} rejected by xueqiu — check the ticker on xueqiu.com`);\n  } else throw e;\n}","preventionTips":["Validate symbols against xueqiu's own site search before scripting","Remember formats: SH/SZ + 6 digits (A-shares), 4-6 digits (HK), 1-5 letters (US)","Watch for delisted/renamed tickers — valid-looking codes can be rejected","Test with a known-good symbol (AAPL, SH600519) when debugging"],"tags":["validation","symbol","xueqiu","argument"],"backgroundTag":"invalid-stock-symbol","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}