jackwener/OpenCLI · error · CommandExecutionError

${label} did not include a stable numeric id.

Error message

${label} did not include a stable numeric id.

What it means

requireStableId validates that a value is a string of only digits, used to guarantee stable numeric IDs (e.g. car IDs scraped from Guazi pages). It throws CommandExecutionError when the value is missing, empty, or contains any non-digit characters after trimming.

Source

Thrown at clis/guazi/utils.js:101

    if (!Number.isInteger(n) || n < 1 || n > max) {
        throw new ArgumentError(`limit must be an integer between 1 and ${max}`);
    }
    return n;
}

export function clean(s) {
    return String(s == null ? '' : s).replace(/\s+/g, ' ').trim();
}

export function requireText(value, label) {
    const text = clean(value);
    if (!text) throw new CommandExecutionError(`${label} did not include a stable text value.`);
    return text;
}

export function requireStableId(value, label) {
    const id = String(value ?? '').trim();
    if (!/^\d+$/.test(id)) throw new CommandExecutionError(`${label} did not include a stable numeric id.`);
    return id;
}

/** Fetch a Guazi mobile page as HTML text, throwing typed errors. */
export async function guaziFetch(path, contextHint) {
    let resp;
    try {
        resp = await fetch(`${GUAZI_M_BASE}${path}`, {
            headers: {
                'User-Agent': UA,
                Referer: `${GUAZI_M_BASE}/`,
                'Accept-Language': 'zh-CN,zh;q=0.9',
            },
        });
    } catch (err) {
        throw new CommandExecutionError(`guazi ${contextHint} network error: ${err?.message || err}`);
    }
    if (!resp.ok) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Extract the bare numeric id before calling, e.g. value.match(/c(\d+)/)?.[1] or strip non-digits
  2. Ensure the CLI argument/flag supplying the id is actually present and populated
  3. Trim and coerce with String(value).trim() yourself and confirm the result matches /^\d+$/
  4. If the source data has no numeric id, use requireStableText (the sibling helper) instead

Example fix

// before
const id = requireStableId('c654321', 'car id');
// throws: car id did not include a stable numeric id.

// after
const id = requireStableId('c654321'.replace(/^c/i, ''), 'car id');
// => '654321'
Defensive patterns

Strategy: validation

Validate before calling

function isStableId(v){ return typeof String(v ?? '').trim() === 'string' && /^\d+$/.test(String(v ?? '').trim()); }
if (!isStableId(raw)) throw new Error('id must be numeric');
requireStableId(raw, 'car id');

Type guard

const isNumericId = (v) => /^\d+$/.test(String(v ?? '').trim());

Try / catch

try {
  const id = requireStableId(value, 'car id');
} catch (e) {
  if (e instanceof CommandExecutionError && /stable numeric id/.test(e.message)) {
    // prompt user / re-derive id from slug
  } else throw e;
}

Prevention

When it happens

Trigger: Calling requireStableId(null), requireStableId(''), requireStableId(' '), requireStableId('abc123'), requireStableId('c123456'), or any value whose String() form is not fully matched by /^\d+$/. Called from clueId when a user-supplied or scraped clue lacks a numeric id.

Common situations: Passing a full car-detail slug like 'c654321' or a URL instead of the bare numeric id; pasting an id with spaces, letters, or a trailing newline; a field that is undefined because an upstream scrape failed or the CLI flag was omitted.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/249b613f3a308caf. Report an issue: GitHub.