{"record":{"id":"42509d95e1eb937d","repo":"jackwener/OpenCLI","slug":"rawinput-does-not-look-like-an-autohome-serie","errorCode":null,"errorMessage":"'${rawInput}' does not look like an autohome series id (a number, or a k.autohome.com.cn/<id> URL)","messagePattern":"'(.+?)' does not look like an autohome series id \\(a number, or a k\\.autohome\\.com\\.cn/<id> URL\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/autohome/utils.js","lineNumber":88,"sourceCode":"    if (!raw) throw new ArgumentError('brand must be a non-empty value');\n    // single A-Z letter passes through (advanced: fetch a whole letter page)\n    if (/^[A-Za-z]$/.test(raw)) return raw.toUpperCase();\n    const key = raw.replace(/[·\\s]/g, '');\n    if (BRAND_INITIAL[key]) return BRAND_INITIAL[key];\n    if (BRAND_INITIAL[raw]) return BRAND_INITIAL[raw];\n    throw new ArgumentError(\n        'brand',\n        `unknown brand '${brandArg}'. Pass a known Chinese brand name (e.g. 宝马 / 比亚迪 / 理想) or a single A-Z catalog letter.`,\n    );\n}\n\n/** Normalize a series id: a bare number or an autohome URL containing it. */\nexport function normalizeSeriesId(rawInput) {\n    const raw = String(rawInput || '').trim();\n    if (!raw) throw new ArgumentError('series_id must be a non-empty value');\n    const m = raw.match(/\\/(?:s)?(\\d+)(?:\\/|$|\\.)/) || raw.match(/^s?(\\d+)$/);\n    if (!m) {\n        throw new ArgumentError(`'${rawInput}' does not look like an autohome series id (a number, or a k.autohome.com.cn/<id> URL)`);\n    }\n    return m[1];\n}\n\nexport function clean(s) {\n    return String(s == null ? '' : s).replace(/\\s+/g, ' ').trim();\n}\n\nexport function requireLimit(value, def, max) {\n    const raw = value == null || value === '' ? def : value;\n    const n = typeof raw === 'number' ? raw : Number(String(raw).trim());\n    if (!Number.isInteger(n) || n < 1 || n > max) {\n        throw new ArgumentError(`limit must be an integer between 1 and ${max}`);\n    }\n    return n;\n}\n\nexport function requireStableId(value, label) {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/autohome/utils.js#L70-L106","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","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"],"exampleFix":"// before\nseriesId('https://k.autohome.com.cn/585.html?utm=x')\n// after\nseriesId('585')","handlingStrategy":"validation","validationCode":"function looksLikeSeriesId(v) {\n  const s = String(v ?? '').trim();\n  return /^s?\\d+$/.test(s) || /\\/(?:s)?\\d+(?:\\/|$|\\.)/.test(s);\n}\nif (!looksLikeSeriesId(raw)) throw new Error('Pass a number or k.autohome.com.cn/<id> URL');","typeGuard":"function isSeriesIdInput(v) {\n  const s = String(v ?? '').trim();\n  return /^s?\\d+$/.test(s) || /\\/(?:s)?\\d+(?:\\/|$|\\.)/.test(s);\n}","tryCatchPattern":"try {\n  const id = seriesId(raw);\n} catch (err) {\n  if (err instanceof ArgumentError && /does not look like/.test(err.message)) {\n    console.error('Expected a numeric id or k.autohome.com.cn/<id> URL, got:', raw);\n  } else throw err;\n}","preventionTips":["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"],"tags":["validation","argument-error","url-parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}