{"record":{"id":"b8ddb0e3fc807a4a","repo":"jackwener/OpenCLI","slug":"not-found-b8ddb0","errorCode":"NOT_FOUND","errorMessage":"No news found","messagePattern":"No news found","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"warning","filePath":"clis/sinafinance/news.js","lineNumber":53,"sourceCode":"        { name: 'type', type: 'int', default: 0, help: 'News type: 0=全部 1=A股 2=宏观 3=公司 4=数据 5=市场 6=国际 7=观点 8=央行 9=其它' },\n    ],\n    columns: ['id', 'time', 'content', 'views'],\n    func: async (args) => {\n        const limit = Math.max(1, Math.min(Number(args.limit), 50));\n        const apiTag = TYPE_MAP[args.type] ?? 0;\n        const params = new URLSearchParams({\n            page: '1',\n            size: String(limit),\n            tag: String(apiTag),\n        });\n        const res = await fetch(`https://app.cj.sina.com.cn/api/news/pc?${params}`);\n        if (!res.ok) {\n            throw new CliError('FETCH_ERROR', `Sina Finance API HTTP ${res.status}`, 'Check your network connection');\n        }\n        const json = await res.json();\n        const list = json?.result?.data?.feed?.list ?? [];\n        if (!list.length) {\n            throw new CliError('NOT_FOUND', 'No news found', 'Try a different type or increase limit');\n        }\n        return list.map((item) => ({\n            id: item.id ?? '',\n            time: item.create_time ?? '',\n            content: stripHtml(item.rich_text ?? ''),\n            views: item.view_num ?? 0,\n        }));\n    },\n});\n","sourceCodeStart":35,"sourceCodeEnd":63,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/sinafinance/news.js#L35-L63","documentation":"CliError with code NOT_FOUND thrown when the Sina Finance news API responds successfully but its feed list is empty. The library treats an empty list as 'no results for this query', not a network failure. It signals the caller should adjust the query parameters rather than retry.","triggerScenarios":"Calling the news command when json.result.data.feed.list is empty (the ?? [] fallback kicks in and list.length === 0). Happens with an obscure/typo'd query keyword, a very small or zero limit, a news type with no recent posts, or an API schema change that moved the feed data.","commonSituations":"Querying a delisted or low-activity stock's news feed; requesting news for a keyword with no Weibo/finance feed entries; Sina silently changing result nesting so the list lookup falls back to []; hitting the API during periods with no feed updates.","solutions":["Check the query keyword/type for typos and retry with a more common term","Increase the limit parameter so more feed entries are eligible","Switch to a different news type supported by the CLI","Verify the API response shape directly (curl the endpoint) to confirm the list is genuinely empty vs a schema change"],"exampleFix":"// before\ncli.news({ key: 'xxxxx', limit: 1 });\n// after\ncli.news({ key: '贵州茅台', limit: 20 });","handlingStrategy":"try-catch","validationCode":"// validate inputs before calling\nif (!key || typeof key !== 'string') throw new Error('key required');\nif (limit != null && (!Number.isInteger(limit) || limit < 1)) throw new Error('limit must be a positive integer');","typeGuard":"function hasNewsList(payload) {\n  return Array.isArray(payload?.result?.data?.feed?.list) && payload.result.data.feed.list.length > 0;\n}","tryCatchPattern":"try {\n  const news = await cli.news({ key, limit });\n} catch (err) {\n  if (err.code === 'NOT_FOUND') {\n    // empty result: adjust query, not a network problem\n    console.warn('No news for this query; try another type or larger limit');\n  } else throw err;\n}","preventionTips":["Use common, well-formed query keywords","Always pass a reasonable limit (e.g. 10-20)","Log the raw API payload once if empty results persist, to rule out schema drift","Treat NOT_FOUND as an expected empty state in automation"],"tags":["empty-result","not-found","api"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}