jackwener/OpenCLI · error · ArgumentError
unknown brand '${brandArg}'. Pass a known Chinese brand name
Error message
unknown brand '${brandArg}'. Pass a known Chinese brand name (e.g. 宝马 / 比亚迪 / 理想) or a single A-Z catalog letter. What it means
ArgumentError thrown by resolveBrandInitial when the brand argument is non-empty but not a single A-Z letter and not found in the BRAND_INITIAL lookup table (after stripping · and whitespace). The library only knows a fixed catalog of Chinese brand names and cannot resolve anything else to an initial letter.
Source
Thrown at clis/autohome/utils.js:76
日产: 'R', 荣威: 'R',
斯巴鲁: 'S', 斯柯达: 'S', 三菱: 'S', 上汽大通: 'S', 思皓: 'S', 赛力斯: 'S', smart: 'S',
特斯拉: 'T', 腾势: 'T', 坦克: 'T',
沃尔沃: 'W', 五菱: 'W', 蔚来: 'W', 威马: 'W', 魏牌: 'W', 问界: 'W',
现代: 'X', 雪佛兰: 'X', 雪铁龙: 'X', 小鹏: 'X', 星途: 'X', 小米: 'X',
英菲尼迪: 'Y', 一汽: 'Y', 野马: 'Y', 仰望: 'Y',
智己: 'Z', 中华: 'Z', 众泰: 'Z',
};
/** Resolve a brand name to its catalog initial letter. */
export function resolveBrandInitial(brandArg) {
const raw = String(brandArg || '').trim();
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();View on GitHub (pinned to 49907e53dc)
Solutions
- Use a known simplified-Chinese brand name from the table, e.g. 宝马, 比亚迪, 理想.
- Alternatively pass a single A-Z catalog letter (e.g. B) to browse that letter's page and find the exact name.
- If the brand is genuinely new, add it to the BRAND_INITIAL map in clis/autohome/utils.js with its correct initial.
Example fix
// before opencli autohome brand 'BMW' // after opencli autohome brand '宝马'
Defensive patterns
Strategy: validation
Validate before calling
const KNOWN = ['宝马','比亚迪','理想']; // extend from BRAND_INITIAL
if (!/^[A-Za-z]$/.test(brand) && !KNOWN.includes(brand)) {
throw new Error(`unknown brand '${brand}' — use a known Chinese name or A-Z letter`);
} Try / catch
try {
await run(['autohome', 'brand', brand]);
} catch (e) {
if (/unknown brand/.test(e.message)) {
console.error('Use simplified Chinese (宝马/比亚迪/理想) or a single letter like B');
} else throw e;
} Prevention
- Maintain a validated brand-name list sourced from BRAND_INITIAL in utils.js.
- Never pass English or pinyin brand names; translate to the official Chinese name first.
- For new brands, extend the BRAND_INITIAL map rather than hoping lookup succeeds.
When it happens
Trigger: Passing an English brand name ('BMW', 'Toyota'), pinyin ('baoma'), an unknown/obscure Chinese brand not in BRAND_INITIAL, or a letter combined with other characters ('AB').
Common situations: Users typing brands in English or pinyin out of habit; brands added to Autohome after the table was written; typos in Chinese characters that miss the lookup key.
Related errors
- ${label} is required
- ${label} must be a positive integer
- ${label} must be <= ${maxValue}
- arxiv ${label} must be a positive integer
- arxiv ${label} must be <= ${maxValue}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/f70df384469a827d.
Report an issue: GitHub.