jackwener/OpenCLI · error · CliError

NO_DATA

NO_DATA

Error message

eastmoney returned no sector data

What it means

After a successful sectors API response, the CLI requires data.data.diff to be a non-empty array. An empty or missing diff means eastmoney returned no sector data for the requested type/sort, so CliError NO_DATA is thrown.

Source

Thrown at clis/eastmoney/sectors.js:62

    const limit = Math.max(1, Math.min(Number(args.limit) || 20, 100));

    const url = new URL('https://push2.eastmoney.com/api/qt/clist/get');
    url.searchParams.set('pn', '1');
    url.searchParams.set('pz', String(limit));
    url.searchParams.set('po', sort.order === 'desc' ? '1' : '0');
    url.searchParams.set('np', '1');
    url.searchParams.set('fltt', '2');
    url.searchParams.set('invt', '2');
    url.searchParams.set('fid', sort.fid);
    url.searchParams.set('fs', fs);
    url.searchParams.set('fields', 'f12,f14,f2,f3,f62,f104,f105,f128,f136,f140,f141');
    url.searchParams.set('ut', 'b2884a393a59ad64002292a3e90d46a5');

    const resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });
    if (!resp.ok) throw new CliError('HTTP_ERROR', `sectors 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 sector data');

    return diff.slice(0, limit).map((it, i) => ({
      rank: i + 1,
      code: it.f12,
      name: it.f14,
      price: it.f2,
      changePercent: it.f3,
      mainNet: it.f62,
      leadStock: it.f128,
      leadChangePercent: it.f136,
      upCount: it.f104,
      downCount: it.f105,
    }));
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the --type value is a supported sector type and try the default
  2. Try a different sort key to see if other queries return data
  3. Call the endpoint directly with curl and the same fs/fid params to inspect the raw payload
  4. Update the CLI if the eastmoney response schema changed

Example fix

// before
sectors({ type: 'concept', sort: 'main' }); // returns empty for this combo
// after
sectors({ type: 'industry', sort: 'change' });
Defensive patterns

Strategy: try-catch

Validate before calling

const KNOWN_TYPES = ['industry','concept'];
if (args.type && !KNOWN_TYPES.includes(String(args.type).toLowerCase())) throw new Error('unsupported sector type');

Type guard

function hasSectorData(data) { return Array.isArray(data?.data?.diff) && data.data.diff.length > 0; }

Try / catch

try {
  const rows = await sectors({ type, sort });
} catch (e) {
  if (e.code === 'NO_DATA') console.warn('eastmoney returned no sector data; try a different type/sort');
  else throw e;
}

Prevention

When it happens

Trigger: Requesting a sector type/fs whose result list is empty (e.g. an unsupported or deprecated fs value), eastmoney returning data:null for the query, or a schema change moving the diff field.

Common situations: eastmoney silently returning empty payloads for some fs values, invalid --type combinations that pass local validation but match nothing server-side, API contract drift after an eastmoney update.

Related errors


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