{"record":{"id":"1b4bd269a95f1b9d","repo":"jackwener/OpenCLI","slug":"sina-finance-rolling-news-api-returned-malformed-r","errorCode":null,"errorMessage":"Sina Finance rolling news API returned malformed row ${index + 1}","messagePattern":"Sina Finance rolling news API returned malformed row (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/sinafinance/rolling-news.js","lineNumber":42,"sourceCode":"}\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,\n            date,\n            url,\n        };\n    });\n}\n\ncli({\n    site: 'sinafinance',\n    name: 'rolling-news',\n    access: 'read',\n    description: '新浪财经滚动新闻',\n    domain: 'feed.mix.sina.com.cn',\n    strategy: Strategy.PUBLIC,\n    browser: false,","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/sinafinance/rolling-news.js#L24-L60","documentation":"CommandExecutionError thrown while mapping rows when an individual item lacks a usable title, url, or derived date. The library requires all three fields per row; a row missing any is reported as malformed with its 1-based index, so one bad row fails the whole batch.","triggerScenarios":"Any item in result.data where title is not a non-empty string, url is missing/empty after trim, or ctime is absent/unparseable so formatRollTimestamp returns falsy — common with ad items, deleted posts, or rows with null fields.","commonSituations":"Sina including promoted/placeholder entries without URLs; rows where ctime is a string instead of a number; partially deleted feed items retaining empty titles.","solutions":["Identify the offending row via the interpolated index and inspect the raw payload","Update the CLI to skip (filter) rows with missing fields instead of throwing","Sanitize/normalize ctime if the API changed its type (string vs number)","Retry — the malformed row may be transient (e.g. a post being edited)"],"exampleFix":"// before\nif (!title || !url || !date) {\n    throw new CommandExecutionError(`... malformed row ${index + 1}`);\n}\n// after\nif (!title || !url || !date) {\n    console.warn(`Skipping malformed row ${index + 1}`);\n    return null;\n}","handlingStrategy":"validation","validationCode":"// validate expected row shape upstream if you control data\nfunction isValidRow(item) {\n  return typeof item?.title === 'string' && item.title.trim() !== '' &&\n         typeof item?.url === 'string' && item.url.trim() !== '' &&\n         Number.isFinite(item?.ctime);\n}","typeGuard":"function isCompleteRollItem(item) {\n  return typeof item?.title === 'string' && item.title.trim().length > 0 &&\n    typeof item?.url === 'string' && item.url.trim().length > 0 &&\n    item?.ctime != null;\n}","tryCatchPattern":"try {\n  const rows = await cli.rollingNews();\n} catch (err) {\n  const m = err.message.match(/malformed row (\\d+)/);\n  if (m) console.error(`Row ${m[1]} missing title/url/date; inspect raw payload`);\n  throw err;\n}","preventionTips":["Inspect the flagged row index in the raw payload to find the missing field","Check whether ctime came back as a string vs number","Retry once — rows being edited can be transiently incomplete","Patch the CLI to skip bad rows instead of failing the whole batch"],"tags":["data-validation","malformed-row","api"],"backgroundTag":"row-validation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}