{"record":{"id":"23d1b8651e1bfaf9","repo":"jackwener/OpenCLI","slug":"sina-finance-rolling-news-api-failed-payload-r","errorCode":null,"errorMessage":"Sina Finance rolling news API failed: ${payload?.result?.status?.msg || 'unknown status'}","messagePattern":"Sina Finance rolling news API failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/sinafinance/rolling-news.js","lineNumber":28,"sourceCode":"\nconst ROLL_API = 'https://feed.mix.sina.com.cn/api/roll/get';\n\nfunction pad2(value) {\n    return String(value).padStart(2, '0');\n}\n\nfunction formatRollTimestamp(value) {\n    const seconds = Number(value);\n    if (!Number.isFinite(seconds) || seconds <= 0)\n        return '';\n    // Sina's roll page presents finance news in China Standard Time.\n    const date = new Date(seconds * 1000 + 8 * 60 * 60 * 1000);\n    return `${pad2(date.getUTCMonth() + 1)}-${pad2(date.getUTCDate())} ${pad2(date.getUTCHours())}:${pad2(date.getUTCMinutes())}`;\n}\n\nfunction normalizeRollRows(payload) {\n    if (payload?.result?.status?.code !== 0) {\n        throw new CommandExecutionError(`Sina Finance rolling news API failed: ${payload?.result?.status?.msg || 'unknown status'}`);\n    }\n    const items = payload?.result?.data;\n    if (!Array.isArray(items)) {\n        throw new CommandExecutionError('Sina Finance rolling news API returned malformed data');\n    }\n    if (items.length === 0) {\n        throw new EmptyResultError('sinafinance rolling-news');\n    }\n    return items.map((item, index) => {\n        const title = typeof item?.title === 'string' ? item.title.trim() : '';\n        const url = typeof item?.url === 'string' ? item.url.trim() : '';\n        const date = formatRollTimestamp(item?.ctime);\n        if (!title || !url || !date) {\n            throw new CommandExecutionError(`Sina Finance rolling news API returned malformed row ${index + 1}`);\n        }\n        return {\n            column: '财经',\n            title,","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/sinafinance/rolling-news.js#L10-L46","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the interpolated status msg to identify the API-reported reason","Retry after a delay — most status failures are transient upstream issues","Verify request parameters against the current Sina rolling news API","Back off and add rate limiting if you are polling in a loop"],"exampleFix":"// before\nawait cli.rollingNews(); // tight polling loop\n// after\nawait new Promise(r => setTimeout(r, 30000));\nawait cli.rollingNews();","handlingStrategy":"retry","validationCode":null,"typeGuard":"function isOkStatus(payload) {\n  return payload?.result?.status?.code === 0;\n}","tryCatchPattern":"try {\n  const rows = await cli.rollingNews();\n} catch (err) {\n  if (/rolling news API failed/.test(err.message)) {\n    // API-reported status != 0; msg is embedded in err.message\n    await sleep(30_000);\n    return retryWithBackoff(() => cli.rollingNews(), 3);\n  }\n  throw err;\n}","preventionTips":["Don't poll the rolling news endpoint in tight loops","Read the embedded status msg before reacting","Add exponential backoff for scheduled jobs","Monitor Sina API status for upstream incidents"],"tags":["api","upstream","sina"],"backgroundTag":"upstream-api-status-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}