jackwener/OpenCLI · error · ArgumentError
'${rawInput}' does not look like an autohome series id (a nu
Error message
'${rawInput}' does not look like an autohome series id (a number, or a k.autohome.com.cn/<id> URL) What it means
normalizeSeriesId() throws this ArgumentError when the input is non-empty but matches neither an autohome URL pattern nor a bare/s-prefixed number. The library cannot extract a numeric series id from it.
Source
Thrown at clis/autohome/utils.js:88
if (!raw) throw new ArgumentError('brand must be a non-empty value');
// single A-Z letter passes through (advanced: fetch a whole letter page)
if (/^[A-Za-z]$/.test(raw)) return raw.toUpperCase();
const key = raw.replace(/[·\s]/g, '');
if (BRAND_INITIAL[key]) return BRAND_INITIAL[key];
if (BRAND_INITIAL[raw]) return BRAND_INITIAL[raw];
throw new ArgumentError(
'brand',
`unknown brand '${brandArg}'. Pass a known Chinese brand name (e.g. 宝马 / 比亚迪 / 理想) or a single A-Z catalog letter.`,
);
}
/** Normalize a series id: a bare number or an autohome URL containing it. */
export function normalizeSeriesId(rawInput) {
const raw = String(rawInput || '').trim();
if (!raw) throw new ArgumentError('series_id must be a non-empty value');
const m = raw.match(/\/(?:s)?(\d+)(?:\/|$|\.)/) || raw.match(/^s?(\d+)$/);
if (!m) {
throw new ArgumentError(`'${rawInput}' does not look like an autohome series id (a number, or a k.autohome.com.cn/<id> URL)`);
}
return m[1];
}
export function clean(s) {
return String(s == null ? '' : s).replace(/\s+/g, ' ').trim();
}
export function requireLimit(value, def, max) {
const raw = value == null || value === '' ? def : value;
const n = typeof raw === 'number' ? raw : Number(String(raw).trim());
if (!Number.isInteger(n) || n < 1 || n > max) {
throw new ArgumentError(`limit must be an integer between 1 and ${max}`);
}
return n;
}
export function requireStableId(value, label) {View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a bare numeric id (e.g. '585') or a URL of the form k.autohome.com.cn/<id>
- Extract the id manually (e.g. from the URL path) and pass just the number
- Trim surrounding labels/whitespace; verify the URL actually contains the numeric series id in its path
Example fix
// before
seriesId('https://k.autohome.com.cn/585.html?utm=x')
// after
seriesId('585') Defensive patterns
Strategy: validation
Validate before calling
function looksLikeSeriesId(v) {
const s = String(v ?? '').trim();
return /^s?\d+$/.test(s) || /\/(?:s)?\d+(?:\/|$|\.)/.test(s);
}
if (!looksLikeSeriesId(raw)) throw new Error('Pass a number or k.autohome.com.cn/<id> URL'); Type guard
function isSeriesIdInput(v) {
const s = String(v ?? '').trim();
return /^s?\d+$/.test(s) || /\/(?:s)?\d+(?:\/|$|\.)/.test(s);
} Try / catch
try {
const id = seriesId(raw);
} catch (err) {
if (err instanceof ArgumentError && /does not look like/.test(err.message)) {
console.error('Expected a numeric id or k.autohome.com.cn/<id> URL, got:', raw);
} else throw err;
} Prevention
- Prefer passing bare numeric ids over URLs
- Strip query strings/fragments and surrounding text from URLs before passing
- Keep a small unit test around any id-extraction helper you write
When it happens
Trigger: seriesId('foo'), seriesId('https://k.autohome.com.cn/spec/123.html?x=1') (query/hash or non-matching URL shape), or values with letters/punctuation like 'series 585'.
Common situations: Pasting a full URL from a different autohome domain or page type; including protocol, query string, or surrounding text; passing a series name instead of its numeric id.
Related errors
- bilibili follow target must be a valid space.bilibili.com/<u
- chatgpt project commands require a chatgpt.com project id or
- Invalid Chess.com game URL: "${value}" Expected https://www.
- event query parameter must be a numeric event id
- event must be an event id, an /events/:id URL, a stats URL w
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/42509d95e1eb937d.
Report an issue: GitHub.