jackwener/OpenCLI · error · CommandExecutionError

Sina Finance rolling news API failed: ${payload?.result?.sta

Error message

Sina Finance rolling news API failed: ${payload?.result?.status?.msg || 'unknown status'}

What it means

CommandExecutionError thrown by normalizeRollRows when the Sina rolling news payload's result.status.code is not 0. The API's status message (result.status.msg) is interpolated into the error; 'unknown status' means the msg field was absent. This is the API-level business-logic failure signal, distinct from HTTP or JSON errors.

Source

Thrown at clis/sinafinance/rolling-news.js:28

const ROLL_API = 'https://feed.mix.sina.com.cn/api/roll/get';

function pad2(value) {
    return String(value).padStart(2, '0');
}

function formatRollTimestamp(value) {
    const seconds = Number(value);
    if (!Number.isFinite(seconds) || seconds <= 0)
        return '';
    // Sina's roll page presents finance news in China Standard Time.
    const date = new Date(seconds * 1000 + 8 * 60 * 60 * 1000);
    return `${pad2(date.getUTCMonth() + 1)}-${pad2(date.getUTCDate())} ${pad2(date.getUTCHours())}:${pad2(date.getUTCMinutes())}`;
}

function normalizeRollRows(payload) {
    if (payload?.result?.status?.code !== 0) {
        throw new CommandExecutionError(`Sina Finance rolling news API failed: ${payload?.result?.status?.msg || 'unknown status'}`);
    }
    const items = payload?.result?.data;
    if (!Array.isArray(items)) {
        throw new CommandExecutionError('Sina Finance rolling news API returned malformed data');
    }
    if (items.length === 0) {
        throw new EmptyResultError('sinafinance rolling-news');
    }
    return items.map((item, index) => {
        const title = typeof item?.title === 'string' ? item.title.trim() : '';
        const url = typeof item?.url === 'string' ? item.url.trim() : '';
        const date = formatRollTimestamp(item?.ctime);
        if (!title || !url || !date) {
            throw new CommandExecutionError(`Sina Finance rolling news API returned malformed row ${index + 1}`);
        }
        return {
            column: '财经',
            title,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the interpolated status msg to identify the API-reported reason
  2. Retry after a delay — most status failures are transient upstream issues
  3. Verify request parameters against the current Sina rolling news API
  4. Back off and add rate limiting if you are polling in a loop

Example fix

// before
await cli.rollingNews(); // tight polling loop
// after
await new Promise(r => setTimeout(r, 30000));
await cli.rollingNews();
Defensive patterns

Strategy: retry

Type guard

function isOkStatus(payload) {
  return payload?.result?.status?.code === 0;
}

Try / catch

try {
  const rows = await cli.rollingNews();
} catch (err) {
  if (/rolling news API failed/.test(err.message)) {
    // API-reported status != 0; msg is embedded in err.message
    await sleep(30_000);
    return retryWithBackoff(() => cli.rollingNews(), 3);
  }
  throw err;
}

Prevention

When it happens

Trigger: Any fetch of the rolling news endpoint where payload.result.status.code !== 0 — e.g. rate limiting, upstream Sina service degradation, malformed/unsupported query params, or an HTML error page parsed as JSON with a different shape.

Common situations: Sina throttling frequent polling; temporary outage of the rolling news backend; a deployed script calling the API with params Sina no longer accepts after an API revision.

Related errors


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