jackwener/OpenCLI · warning · CliError
NO_DATA
NO_DATA
Error message
eastmoney returned no index data
What it means
This CliError with code NO_DATA is thrown when the Eastmoney index API answers HTTP 200 but data.data.diff is missing, not an array, or empty. The library treats an empty diff array as 'no index data' rather than returning an empty board. It means the request succeeded but the payload contained no usable quotes.
Source
Thrown at clis/eastmoney/index-board.js:74
entries = [...INDEX_GROUPS.main, ...INDEX_GROUPS.hk, ...INDEX_GROUPS.us];
} else if (INDEX_GROUPS[group]) {
entries = INDEX_GROUPS[group];
} else {
throw new CliError('INVALID_ARGUMENT', `Unknown group "${group}". Valid: main, hk, us, all`);
}
const secids = entries.map(([secid]) => secid).join(',');
const url = new URL('https://push2.eastmoney.com/api/qt/ulist.np/get');
url.searchParams.set('secids', secids);
url.searchParams.set('fltt', '2');
url.searchParams.set('fields', FIELDS);
url.searchParams.set('ut', 'bd1d9ddb04089700cf9c27f6f7426281');
const resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0', Accept: 'application/json' } });
if (!resp.ok) throw new CliError('HTTP_ERROR', `eastmoney index-board failed: HTTP ${resp.status}`);
const data = await resp.json();
const diff = Array.isArray(data?.data?.diff) ? data.data.diff : [];
if (diff.length === 0) throw new CliError('NO_DATA', 'eastmoney returned no index data');
// Preserve the order defined in INDEX_GROUPS regardless of API ordering
const byCode = new Map(diff.map((it) => [String(it.f12), it]));
return entries
.map(([secid, fallbackName]) => {
const code = secid.split('.')[1];
const it = byCode.get(code);
if (!it) return null;
return {
code,
name: it.f14 || fallbackName,
price: it.f2,
changePercent: it.f3,
change: it.f4,
open: it.f17,
high: it.f15,
low: it.f16,
prevClose: it.f18,View on GitHub (pinned to 49907e53dc)
Solutions
- Verify each secid uses the correct market prefix (Shanghai indexes like 1.000001/1.000300, Shenzhen 0.399001)
- Check Eastmoney's web index board to confirm the API is currently returning data at all
- Log/re-inspect the raw response body once to see if the schema changed (e.g. diff moved or renamed)
- Treat NO_DATA as retryable with a short backoff if it happens sporadically; escalate if persistent
- Update FIELDS/endpoint if Eastmoney changed the API contract
Example fix
// before
const diff = Array.isArray(data?.data?.diff) ? data.data.diff : [];
if (diff.length === 0) throw new CliError('NO_DATA', 'eastmoney returned no index data');
// after (caller side)
try {
const board = await getIndexBoard({ group: 'main' });
} catch (e) {
if (e.code === 'NO_DATA') return []; // render empty board instead of crashing
throw e;
} Defensive patterns
Strategy: fallback
Validate before calling
function validateSecidPrefixes(secids) {
// Shanghai indexes use prefix 1, Shenzhen use 0 — wrong prefixes yield empty diff with HTTP 200
return secids.every((s) => /^(1\.0\d{5}|0\.3\d{5})$/.test(s));
} Type guard
function hasIndexData(data) {
return Array.isArray(data?.data?.diff) && data.data.diff.length > 0;
} Try / catch
try {
return await getIndexBoard({ group });
} catch (err) {
if (err.code === 'NO_DATA') {
return FALLBACK_BOARD; // cached/last-known-good board or empty array
}
throw err;
} Prevention
- Double-check market prefixes on every secid (1. for SH, 0. for SZ indexes)
- Cache the last successful board and serve it when the API returns empty
- Retry briefly on NO_DATA — some empty payloads are transient
- Keep an eye on Eastmoney API schema changes; log raw bodies when diff is empty
When it happens
Trigger: All requested secids are invalid/unknown to the ulist.np/get endpoint (Eastmoney often returns 200 with null data instead of an error); Eastmoney returning {data: null} during maintenance; an API contract change where quotes moved to a different field; passing a group whose secids are all mistyped.
Common situations: Constructing custom secid lists with wrong market prefixes (e.g. 0.000300 instead of 1.000300 for CSI indexes); Eastmoney field naming changes (f12 etc.) after an API update; transient backend hiccups returning empty payloads; querying outside market data availability windows in rare maintenance windows.
Related errors
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/802eecacbfc4c054.
Report an issue: GitHub.