jackwener/OpenCLI · error · ArgumentError
series_id must be a non-empty value
Error message
series_id must be a non-empty value
What it means
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.
Source
Thrown at clis/dongchedi/utils.js:151
throw new CommandExecutionError(`${label} did not include a stable text value.`);
}
return text;
}
/** Rescale a Dongchedi x100 score int (422) to a /5 float (4.22). */
export function parseScore(raw) {
const n = Number(raw);
if (!Number.isFinite(n) || n <= 0) return null;
return Number((n / 100).toFixed(2));
}
/**
* Normalize a series id argument: a bare number, or a
* `https://www.dongchedi.com/auto/series/<id>` URL.
*/
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(/series\/(\d+)/) || raw.match(/^(\d+)$/);
if (!m) {
throw new ArgumentError(
`'${rawInput}' does not look like a dongchedi series id (a number, or a /auto/series/<id> URL)`,
);
}
return m[1];
}
/** Validate an integer limit in [1, max]. */
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;
}View on GitHub (pinned to 49907e53dc)
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
Example fix
// before
await seriesId(process.env.MISSING_ID);
// after
const id = process.env.SERIES_ID;
if (!id || !id.trim()) throw new Error('SERIES_ID env var must be set');
await seriesId(id); Defensive patterns
Strategy: validation
Validate before calling
const raw = String(input ?? '').trim();
if (!raw) throw new Error('series_id is required: pass a number or a dongchedi /auto/series/<id> URL'); Type guard
function hasSeriesId(v) { return v != null && String(v).trim() !== ''; } Try / catch
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; } Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- '${rawInput}' does not look like a dongchedi series id (a nu
- Unknown 12306 station telecode "${trimmed}"
- Unknown 12306 station "${trimmed}"
- date must be YYYY-MM-DD, got "${value}"
- date "${value}" is not a real calendar date
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/1d2269976aa2afc7.
Report an issue: GitHub.