jackwener/OpenCLI · warning · CliError

NO_DATA

NO_DATA

Error message

ths hot-rank API returned no stock data

What it means

After a successful HTTP 200, the ths hot-rank command expects payload.data.stock_list to be a non-empty array. If it's empty or missing, CliError NO_DATA is thrown — the API responded but contained no rank rows.

Source

Thrown at clis/ths/hot-rank.js:46

  strategy: Strategy.PUBLIC,
  browser: false,
  args: [
    { name: 'limit', type: 'int', default: 20, help: '返回数量' },
  ],
  columns: ['rank', 'name', 'changePercent', 'heat', 'tags'],
  func: async (args) => {
    const limit = parseLimit(args.limit);
    const resp = await fetch(THS_HOT_API_URL, {
      headers: {
        'Accept': 'application/json,text/plain,*/*',
        'User-Agent': 'Mozilla/5.0',
        'Referer': 'https://eq.10jqka.com.cn/',
      },
    });
    if (!resp.ok) throw new CliError('HTTP_ERROR', `ths hot-rank failed: HTTP ${resp.status}`);
    const payload = await resp.json();
    const stocks = Array.isArray(payload?.data?.stock_list) ? payload.data.stock_list : [];
    if (stocks.length === 0) throw new CliError('NO_DATA', 'ths hot-rank API returned no stock data');

    return stocks.slice(0, limit).map((stock, index) => ({
      rank: stock.order ?? index + 1,
      name: stock.name ?? '',
      changePercent: stock.rise_and_fall ?? '',
      heat: stock.rate ?? '',
      tags: tagsFromStock(stock),
    }));
  },
});

export const __test__ = {
  THS_HOT_API_URL,
  parseLimit,
  tagsFromStock,
};

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry during trading hours when the ranking has data
  2. Log the full payload on failure and update the payload?.data?.stock_list path if the schema changed in clis/ths/hot-rank.js
  3. Treat as expected-empty in your wrapper (catch NO_DATA and return []) if an empty market is acceptable
  4. Verify the endpoint in a browser devtools network tab to confirm the current field layout
Defensive patterns

Strategy: fallback

Type guard

function hasStockList(payload) {
  return Array.isArray(payload?.data?.stock_list) && payload.data.stock_list.length > 0;
}

Try / catch

let stocks;
try {
  stocks = await thsHotRank({ limit });
} catch (e) {
  if (e?.code === 'NO_DATA') stocks = []; // market closed / empty rank
  else throw e;
}

Prevention

When it happens

Trigger: eq.10jqka.com.cn hot-rank endpoint returns JSON without data.stock_list (empty array, null, or different shape), e.g. market closed/pre-market with no ranked data, or response schema changed.

Common situations: Querying during non-trading hours when the rank list is empty; API contract drift after a site update; partial responses during maintenance windows.

Related errors


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