jackwener/OpenCLI · warning · ArgumentError
Unknown sort "${sortKey}". Valid: ${Object.keys(SORTS).join(
Error message
Unknown sort "${sortKey}". Valid: ${Object.keys(SORTS).join(', ')} What it means
ArgumentError thrown in the cli func (clis/eastmoney/convertible.js:135) when the `--sort` value, lowercased, is not a key of SORTS. Valid keys: change, drop, turnover, price, premium, value, put-trigger. The message lists all valid options. This is a client-side argument validation error; no network request is made.
Source
Thrown at clis/eastmoney/convertible.js:135
}
cli({
site: 'eastmoney',
name: 'convertible',
access: 'read',
description: '可转债行情列表(默认按成交额排序)',
domain: 'push2.eastmoney.com',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'sort', type: 'string', default: 'turnover', help: '排序:turnover / change / drop / price / premium / value / put-trigger' },
{ name: 'limit', type: 'int', default: 20, help: '返回数量 (max 100)' },
],
columns: ['rank', 'bondCode', 'bondName', 'bondPrice', 'bondChangePct', 'stockCode', 'stockName', 'stockPrice', 'stockChangePct', 'convPrice', 'convValue', 'convPremiumPct', 'pureBondPremiumPct', 'putTriggerPrice', 'listDate'],
func: async (args) => {
const sortKey = String(args.sort ?? 'turnover').toLowerCase();
const sort = SORTS[sortKey];
if (!sort) throw new ArgumentError(`Unknown sort "${sortKey}". Valid: ${Object.keys(SORTS).join(', ')}`);
const limit = parseConvertibleLimit(args.limit);
const url = new URL('https://push2.eastmoney.com/api/qt/clist/get');
url.searchParams.set('pn', '1');
url.searchParams.set('pz', String(limit));
url.searchParams.set('po', sort.order === 'desc' ? '1' : '0');
url.searchParams.set('np', '1');
url.searchParams.set('fltt', '2');
url.searchParams.set('invt', '2');
url.searchParams.set('fid', sort.fid);
url.searchParams.set('fs', 'b:MK0354');
url.searchParams.set('fields', 'f12,f14,f2,f3,f6,f229,f230,f232,f234,f235,f236,f237,f238,f239,f243');
url.searchParams.set('ut', 'bd1d9ddb04089700cf9c27f6f7426281');
const resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });
if (!resp.ok) throw new CommandExecutionError(`eastmoney convertible failed: HTTP ${resp.status}`);
let data;
try {View on GitHub (pinned to 49907e53dc)
Solutions
- Use one of the listed keys: turnover (default), change, drop, price, premium, value, put-trigger.
- Replace legacy sort names: `--sort ytm`/`--sort remainingYears` → `--sort put-trigger` (per #2109 rename).
- Check for typos and stray whitespace/quotes in the shell argument.
- Run with no --sort to get the turnover-sorted default.
Example fix
// before opencli eastmoney convertible --sort ytm // after opencli eastmoney convertible --sort put-trigger
Defensive patterns
Strategy: validation
Validate before calling
const VALID_SORTS = ['change','drop','turnover','price','premium','value','put-trigger'];
const sortKey = String(args.sort ?? 'turnover').toLowerCase();
if (!VALID_SORTS.includes(sortKey)) throw new Error(`--sort must be one of: ${VALID_SORTS.join(', ')}`); Try / catch
try {
await run(['eastmoney', 'convertible', '--sort', sortKey]);
} catch (e) {
if (String(e.message).startsWith('Unknown sort')) {
console.error(`Invalid sort "${sortKey}"; using default turnover`);
await run(['eastmoney', 'convertible']);
} else throw e;
} Prevention
- Use only documented keys: change, drop, turnover, price, premium, value, put-trigger.
- Migrate legacy `ytm`/`remainingYears` sorts to `put-trigger` (issue #2109 rename).
- Trim and lowercase user-supplied sort values before passing.
- Check `--help` for the current sort list rather than reusing other CLIs' keys.
When it happens
Trigger: Running `opencli eastmoney convertible --sort ytm` (removed per #2109) or any misspelled/unknown key like `remaining`, `conv`, or a value with trailing whitespace that lowercases to something unknown. Also fires when scripts pass programmatic sort values not in SORTS.
Common situations: Older scripts using the pre-#2109 sort names `ytm` or `remainingYears` that were renamed to `put-trigger`; typos; shell variables containing empty or garbage sort values; users copying sort names from other eastmoney CLIs (e.g. etf.js uses a different SORTS map).
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
- INVALID_ARGUMENT
- coingecko limit must be a positive integer
- unknown mode "${mode}"
- Unknown tag: ${value}
- Unknown category: ${value}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/8cf828bd6244a6fe.
Report an issue: GitHub.