jackwener/OpenCLI · error · ArgumentError
xueqiu comments requires a symbol
Error message
xueqiu comments requires a symbol
What it means
normalizeSymbolInput in clis/xueqiu/comments.js normalizes the required positional symbol argument and throws this ArgumentError when the raw input is missing, null, undefined, or whitespace-only. A symbol is mandatory for building the xueqiu comments API request.
Source
Thrown at clis/xueqiu/comments.js:347
limit,
pageSize,
maxRequests: 5,
fetchPage: (pageNumber, currentPageSize) => fetchCommentsPage(page, symbol, pageNumber, currentPageSize),
warn: log.warn,
});
return rows.map(row => toCommentOutputRow(row));
},
});
/**
* Convert raw CLI input into a normalized stock symbol.
*
* @param raw User-provided CLI argument.
* @returns Upper-cased symbol string.
*/
export function normalizeSymbolInput(raw) {
const symbol = String(raw ?? '').trim().toUpperCase();
if (!symbol)
throw new ArgumentError('xueqiu comments requires a symbol');
if (/^HTTPS?:\/\//.test(symbol)) {
throw new ArgumentError('xueqiu comments only accepts a symbol, not a URL');
}
if (!XUEQIU_SYMBOL_PATTERN.test(symbol)) {
throw new ArgumentError(`xueqiu comments received an invalid symbol: ${symbol}`);
}
return symbol;
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Provide the positional symbol, e.g. clis/xueqiu comments SH600519.
- In scripts, guard the variable before calling: [ -n "$SYMBOL" ] || exit 1.
- Trim whitespace from config-driven values before passing them.
Example fix
// before clis/xueqiu comments // after clis/xueqiu comments SH600519
Defensive patterns
Strategy: validation
Validate before calling
const symbol = (rawSymbol ?? '').trim();
if (!symbol) throw new Error('symbol is required'); Type guard
const hasSymbol = (v) => typeof v === 'string' && v.trim().length > 0;
Prevention
- Always include the positional symbol argument.
- Guard interpolated shell variables for emptiness before invoking.
- Trim config-driven values before passing.
When it happens
Trigger: Calling the comments command without the positional symbol argument, or passing an empty string, whitespace, null, or undefined (String(raw ?? '').trim() yields '').
Common situations: Scripting with an unset shell variable (symbol="$SYMBOL" where SYMBOL is empty), forgetting the positional argument entirely, or a config file providing a blank symbol.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- keyword must not be empty
- <from> station must not be empty
- <to> station must not be empty
- who 不能为空
- key is required
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/0600fe2e443a6f40.
Report an issue: GitHub.