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() throws CommandExecutionError when the value extracted from a fetched page (labeled by `label`) is not purely numeric digits. Autohome identifiers must be stable numeric ids; the library treats a missing/invalid one as an unexpected page payload rather than user error.
Source
Thrown at clis/autohome/utils.js:108
return m[1];
}
export function clean(s) {
return String(s == null ? '' : s).replace(/\s+/g, ' ').trim();
}
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;
}
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;
}
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 assertPlainObject(value, label) {
if (!value || typeof value !== 'object' || Array.isArray(value)) {
throw new CommandExecutionError(`${label} returned an unexpected payload shape; expected an object.`);
}
return value;
}
/** Fetch an Autohome page as text. The grade + koubei pages are UTF-8. */
export async function ahFetch(url, contextHint) {View on GitHub (pinned to 49907e53dc)
Solutions
- Verify the source page actually rendered the entity and inspect what `label` contained
- Retry the fetch in case of an anti-bot/interstitial page
- If you supply the value yourself, pass the numeric id, not a name or URL slug
Example fix
// before requireStableId(result.name, 'series') // after requireStableId(String(result.id), 'series')
Defensive patterns
Strategy: type-guard
Validate before calling
if (!/^\d+$/.test(String(value ?? '').trim())) {
throw new Error('Expected a numeric id for ' + label);
} Type guard
function isNumericId(v) {
return /^\d+$/.test(String(v ?? '').trim());
} Try / catch
try {
const id = requireStableId(value, label);
} catch (err) {
if (err instanceof CommandExecutionError && /stable numeric id/.test(err.message)) {
console.error(`Page did not yield a numeric id for ${label}; check the page or retry`);
} else throw err;
} Prevention
- Verify pages render expected data (open the URL manually) before blaming your code
- Retry fetches that hit anti-bot/interstitial pages
- Pass ids, not names/slugs, into functions expecting stable ids
When it happens
Trigger: A scraped page lacks the id (layout changed, region-specific page, anti-bot interstitial) so an empty or non-numeric string is passed; or the caller passes a name/slug instead of the numeric id.
Common situations: Autohome markup changes breaking extraction; logged-out or CAPTCHA pages returning fallback content; hardcoding a label where an id is expected.
Understand the failure class
Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.
Related errors
- ${label} did not include a stable text value.
- github-trending parser drift: invalid repository identity "$
- Title not found: ${id}
- Could not find chart data on page
- Nowcoder returned a malformed ${label}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a4ea26a8a26c02e1.
Report an issue: GitHub.