{"record":{"id":"171bd9f753270517","repo":"jackwener/OpenCLI","slug":"xueqiu-comments-requires-limit-to-be-a-positive","errorCode":null,"errorMessage":"xueqiu comments requires --limit to be a positive integer","messagePattern":"xueqiu comments requires --limit to be a positive integer","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/xueqiu/comments.js","lineNumber":320,"sourceCode":"    domain: 'xueqiu.com',\n    strategy: Strategy.COOKIE,\n    browser: true,\n    navigateBefore: false,\n    args: [\n        {\n            name: 'symbol',\n            positional: true,\n            required: true,\n            help: 'Stock symbol, e.g. SH600519, AAPL, or 00700',\n        },\n        { name: 'limit', type: 'int', default: 20, help: 'Number of discussion posts to return' },\n    ],\n    columns: ['author', 'text', 'likes', 'replies', 'retweets', 'created_at', 'url'],\n    func: async (page, args) => {\n        const symbol = normalizeSymbolInput(args.symbol);\n        const limit = Number(args.limit);\n        if (!Number.isInteger(limit) || limit <= 0) {\n            throw new ArgumentError('xueqiu comments requires --limit to be a positive integer');\n        }\n        if (limit > 100) {\n            throw new ArgumentError('xueqiu comments supports --limit up to 100');\n        }\n        const pageSize = Math.min(limit, 20);\n        await page.goto('https://xueqiu.com');\n        const rows = await collectCommentRows({\n            symbol,\n            limit,\n            pageSize,\n            maxRequests: 5,\n            fetchPage: (pageNumber, currentPageSize) => fetchCommentsPage(page, symbol, pageNumber, currentPageSize),\n            warn: log.warn,\n        });\n        return rows.map(row => toCommentOutputRow(row));\n    },\n});\n/**","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xueqiu/comments.js#L302-L338","documentation":"The xueqiu comments CLI command validates the --limit argument before scraping. It converts --limit with Number() and requires it to be an integer greater than 0; otherwise it throws this ArgumentError. The library throws it because pagination (pageSize = min(limit, 20), max 5 requests) only makes sense with a finite positive count.","triggerScenarios":"Running the xueqiu comments command with --limit as a non-integer (e.g. --limit 10.5), a non-numeric string (e.g. --limit abc or --limit ''), zero, or a negative number. Internally: Number(args.limit) yields NaN, a float, or <= 0.","commonSituations":"Typos in the CLI invocation, scripting that interpolates an empty or undefined variable as --limit value, copy-pasting a default like --limit=null, or passing a range/expression like --limit 1-100.","solutions":["Pass --limit as a plain positive integer, e.g. --limit 20.","Check the interpolated value in shell scripts: quote and default it, e.g. --limit \"${LIMIT:-20}\".","If you need more than the cap, note the separate error for limit > 100; 100 is the maximum.","If calling the function programmatically, coerce/validate the number yourself before invoking."],"exampleFix":"// before\nclis/xueqiu comments SH600519 --limit abc\n// after\nclis/xueqiu comments SH600519 --limit 20","handlingStrategy":"validation","validationCode":"const limit = Number(rawLimit);\nif (!Number.isInteger(limit) || limit <= 0) {\n  throw new Error(`--limit must be a positive integer, got: ${rawLimit}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --limit as a plain integer literal.","Default shell variables: --limit \"${LIMIT:-20}\" and check non-empty before use.","Clamp inputs in scripts: [ \"$LIMIT\" -ge 1 ] || LIMIT=20."],"tags":["cli","argument-validation","xueqiu"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}