jackwener/OpenCLI · error · ArgumentError
xueqiu comments only accepts a symbol, not a URL
Error message
xueqiu comments only accepts a symbol, not a URL
What it means
normalizeSymbolInput rejects inputs that look like URLs (case-insensitively matching /^HTTPS?:\/\// after upper-casing). The command wants a bare ticker symbol, not a pasted xueqiu page URL, so users copying a link from the browser get this ArgumentError.
Source
Thrown at clis/xueqiu/comments.js:349
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
- Use the bare symbol instead of the URL, e.g. SH600519.
- Extract the code from the URL if needed: the segment after /S/ (e.g. SH600519 from https://xueqiu.com/S/SH600519).
- Strip or parse URLs in scripts before invoking the command.
Example fix
// before clis/xueqiu comments https://xueqiu.com/S/SH600519 // after clis/xueqiu comments SH600519
Defensive patterns
Strategy: validation
Validate before calling
if (/^https?:\/\//i.test(rawSymbol)) {
rawSymbol = new URL(rawSymbol).pathname.split('/').pop(); // extract /S/<code>
} Type guard
const isUrl = (v) => typeof v === 'string' && /^https?:\/\//i.test(v.trim());
Prevention
- Never paste full xueqiu URLs as the symbol.
- Extract the code after /S/ when starting from a URL.
- Sanitize inputs in automation pipelines.
When it happens
Trigger: Passing something like https://xueqiu.com/S/SH600519 or http://xueqiu.com/S/AAPL as the symbol argument.
Common situations: Copying the stock's xueqiu page URL from a browser address bar and pasting it directly as the argument, or automation that extracts links instead of symbols.
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 requires --limit to be a positive integer
- xueqiu comments supports --limit up to 100
- <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/5ea33fe3bcf88ea1.
Report an issue: GitHub.