jackwener/OpenCLI · error · ArgumentError
xueqiu comments requires --limit to be a positive integer
Error message
xueqiu comments requires --limit to be a positive integer
What it means
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.
Source
Thrown at clis/xueqiu/comments.js:320
domain: 'xueqiu.com',
strategy: Strategy.COOKIE,
browser: true,
navigateBefore: false,
args: [
{
name: 'symbol',
positional: true,
required: true,
help: 'Stock symbol, e.g. SH600519, AAPL, or 00700',
},
{ name: 'limit', type: 'int', default: 20, help: 'Number of discussion posts to return' },
],
columns: ['author', 'text', 'likes', 'replies', 'retweets', 'created_at', 'url'],
func: async (page, args) => {
const symbol = normalizeSymbolInput(args.symbol);
const limit = Number(args.limit);
if (!Number.isInteger(limit) || limit <= 0) {
throw new ArgumentError('xueqiu comments requires --limit to be a positive integer');
}
if (limit > 100) {
throw new ArgumentError('xueqiu comments supports --limit up to 100');
}
const pageSize = Math.min(limit, 20);
await page.goto('https://xueqiu.com');
const rows = await collectCommentRows({
symbol,
limit,
pageSize,
maxRequests: 5,
fetchPage: (pageNumber, currentPageSize) => fetchCommentsPage(page, symbol, pageNumber, currentPageSize),
warn: log.warn,
});
return rows.map(row => toCommentOutputRow(row));
},
});
/**View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before clis/xueqiu comments SH600519 --limit abc // after clis/xueqiu comments SH600519 --limit 20
Defensive patterns
Strategy: validation
Validate before calling
const limit = Number(rawLimit);
if (!Number.isInteger(limit) || limit <= 0) {
throw new Error(`--limit must be a positive integer, got: ${rawLimit}`);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- xueqiu comments supports --limit up to 100
- xueqiu comments only accepts a symbol, not a URL
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/171bd9f753270517.
Report an issue: GitHub.