jackwener/OpenCLI · warning · CliError
NOT_FOUND
NOT_FOUND
Error message
No news found
What it means
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.
Source
Thrown at clis/sinafinance/news.js:53
{ name: 'type', type: 'int', default: 0, help: 'News type: 0=全部 1=A股 2=宏观 3=公司 4=数据 5=市场 6=国际 7=观点 8=央行 9=其它' },
],
columns: ['id', 'time', 'content', 'views'],
func: async (args) => {
const limit = Math.max(1, Math.min(Number(args.limit), 50));
const apiTag = TYPE_MAP[args.type] ?? 0;
const params = new URLSearchParams({
page: '1',
size: String(limit),
tag: String(apiTag),
});
const res = await fetch(`https://app.cj.sina.com.cn/api/news/pc?${params}`);
if (!res.ok) {
throw new CliError('FETCH_ERROR', `Sina Finance API HTTP ${res.status}`, 'Check your network connection');
}
const json = await res.json();
const list = json?.result?.data?.feed?.list ?? [];
if (!list.length) {
throw new CliError('NOT_FOUND', 'No news found', 'Try a different type or increase limit');
}
return list.map((item) => ({
id: item.id ?? '',
time: item.create_time ?? '',
content: stripHtml(item.rich_text ?? ''),
views: item.view_num ?? 0,
}));
},
});
View on GitHub (pinned to 49907e53dc)
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
Example fix
// before
cli.news({ key: 'xxxxx', limit: 1 });
// after
cli.news({ key: '贵州茅台', limit: 20 }); Defensive patterns
Strategy: try-catch
Validate before calling
// validate inputs before calling
if (!key || typeof key !== 'string') throw new Error('key required');
if (limit != null && (!Number.isInteger(limit) || limit < 1)) throw new Error('limit must be a positive integer'); Type guard
function hasNewsList(payload) {
return Array.isArray(payload?.result?.data?.feed?.list) && payload.result.data.feed.list.length > 0;
} Try / catch
try {
const news = await cli.news({ key, limit });
} catch (err) {
if (err.code === 'NOT_FOUND') {
// empty result: adjust query, not a network problem
console.warn('No news for this query; try another type or larger limit');
} else throw err;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- bilibili creator-stats ${bvid}
- Chess.com returned 404 for ${url}
- crates crate
- crates.io returned 404 for ${url}.
- devto/${id}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b8ddb0e3fc807a4a.
Report an issue: GitHub.