jackwener/OpenCLI · error · ArgumentError
${label} must be a numeric ID
Error message
${label} must be a numeric ID What it means
normalizeNumericId validates that an ID argument (for sku, itemId, userId commands) is a string of digits only. Anything else — including numbers with signs, decimals, whitespace-plus-symbols, or alphanumeric IDs — raises an ArgumentError instructing the caller to pass a numeric ID with an example.
Source
Thrown at clis/xianyu/utils.js:5
import { ArgumentError } from '@jackwener/opencli/errors';
export function normalizeNumericId(value, label, example) {
const normalized = String(value || '').trim();
if (!/^\d+$/.test(normalized)) {
throw new ArgumentError(`${label} must be a numeric ID`, `Pass a numeric ${label}, for example: ${example}`);
}
return normalized;
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Pass only the digits of the ID, e.g. xianyu item 812345678901
- Extract the id query parameter from an item URL instead of pasting the whole URL
- Trim whitespace/control characters from the value before passing it
- Confirm you are not using a share token or short code in place of the numeric ID
Example fix
// before xianyu item 'https://www.goofish.com/item?id=812345678901' // after xianyu item 812345678901
Defensive patterns
Strategy: validation
Validate before calling
function assertNumericId(v){ const s=String(v??'').trim(); if(!/^\d+$/.test(s)) throw new Error(`ID must be numeric digits, got: ${v}`); return s; }
const id = assertNumericId(rawId); Type guard
const isNumericId = (v) => typeof v === 'string' || typeof v === 'number' ? /^\d+$/.test(String(v).trim()) : false;
Try / catch
try { await xianyuItem(id); } catch (e) { if (e instanceof ArgumentError && /must be a numeric ID/.test(e.message)) { const m = String(rawId).match(/[?&]id=(\d+)/); if (m) return xianyuItem(m[1]); } throw e; } Prevention
- Extract the numeric id from item URLs (the ?id= query param) instead of pasting the URL
- Trim whitespace and copy IDs without surrounding characters
- Never pass share codes, short links, or decimal/negative numbers as IDs
When it happens
Trigger: Calling `xianyu sku` / `xianyu item` / `xianyu user` with a non-numeric ID such as 'abc123', '1.5', '-42', a full item URL pasted instead of the ID, or an empty/null value.
Common situations: Pasting a goofish.com item URL (https://www.goofish.com/item?id=123...) instead of extracting the id query param, copying an ID with trailing spaces/invisible characters, or confusing numeric item IDs with alphanumeric share codes.
Related errors
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
- --seat-types must contain only 12306 seat letters/digits (A-
- --from and --to must differ; both resolved to ${fromStation.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/3b3769535c8fc5b7.
Report an issue: GitHub.