{"record":{"id":"1d2269976aa2afc7","repo":"jackwener/OpenCLI","slug":"series-id-must-be-a-non-empty-value-1d2269","errorCode":null,"errorMessage":"series_id must be a non-empty value","messagePattern":"series_id must be a non-empty value","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/dongchedi/utils.js","lineNumber":151,"sourceCode":"        throw new CommandExecutionError(`${label} did not include a stable text value.`);\n    }\n    return text;\n}\n\n/** Rescale a Dongchedi x100 score int (422) to a /5 float (4.22). */\nexport function parseScore(raw) {\n    const n = Number(raw);\n    if (!Number.isFinite(n) || n <= 0) return null;\n    return Number((n / 100).toFixed(2));\n}\n\n/**\n * Normalize a series id argument: a bare number, or a\n * `https://www.dongchedi.com/auto/series/<id>` URL.\n */\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(/series\\/(\\d+)/) || raw.match(/^(\\d+)$/);\n    if (!m) {\n        throw new ArgumentError(\n            `'${rawInput}' does not look like a dongchedi series id (a number, or a /auto/series/<id> URL)`,\n        );\n    }\n    return m[1];\n}\n\n/** Validate an integer limit in [1, max]. */\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}","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/dongchedi/utils.js#L133-L169","documentation":"normalizeSeriesId validates the series_id argument before any network call. It throws ArgumentError when the input is empty/nullish after trimming, because a series id is mandatory to identify a dongchedi car series. This is an input-validation guard, not a network or auth failure.","triggerScenarios":"Calling seriesId() with no argument, with undefined/null, with an empty string, or with a value that trims to '' (e.g. empty shell variable or missing CLI arg).","commonSituations":"A script reads SERIES_ID from an unset environment variable; a CLI user forgets the positional argument; a caller passes a number 0 or a falsy placeholder.","solutions":["Pass a valid series id: a bare number like 4694 or a URL https://www.dongchedi.com/auto/series/4694","Check that the variable/arg feeding series_id is set and non-empty before calling","Print/inspect the input value to confirm it is not empty after trimming"],"exampleFix":"// before\nawait seriesId(process.env.MISSING_ID);\n// after\nconst id = process.env.SERIES_ID;\nif (!id || !id.trim()) throw new Error('SERIES_ID env var must be set');\nawait seriesId(id);","handlingStrategy":"validation","validationCode":"const raw = String(input ?? '').trim();\nif (!raw) throw new Error('series_id is required: pass a number or a dongchedi /auto/series/<id> URL');","typeGuard":"function hasSeriesId(v) { return v != null && String(v).trim() !== ''; }","tryCatchPattern":"try { await seriesId(input); } catch (e) { if (e.name === 'ArgumentError') { console.error('Provide a numeric series id or a dongchedi series URL'); } else throw e; }","preventionTips":["Require the series_id CLI arg explicitly and error early with usage help","Check env vars are non-empty before passing them","Prefer full /auto/series/<id> URLs when storing ids"],"tags":["argument-error","input-validation","dongchedi"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}