DIYgod/RSSHub · error · Error
${response.data.return_msg}
Error message
${response.data.return_msg} What it means
Same envelope-pattern guard as the home route, but in niaogebiji/today (今日事) which POSTs to /pc/bulletin/index. The response.data.return_code is checked; non-'200' values re-throw response.data.return_msg. Because the response is wrapped one level deeper (response.data), this also implicitly breaks if the request itself is not JSON.
Source
Thrown at lib/routes/niaogebiji/today.ts:42
name: '今日事',
maintainers: ['KotoriK'],
handler,
url: 'niaogebiji.com/',
};
async function handler() {
const response = await got({
method: 'post',
url: 'https://www.niaogebiji.com/pc/bulletin/index',
form: {
page: 1,
pub_time: '',
isfromajax: 1,
},
});
if (response.data.return_code !== '200') {
throw new Error(response.data.return_msg);
}
const data = response.data.return_data;
return {
title: '鸟哥笔记-今日事',
link: 'https://www.niaogebiji.com/bulletin',
item: data.map((item) => ({
title: item.title,
description: item.content,
link: item.url,
pubDate: parseDate(item.pub_time, 'X'),
updated: parseDate(item.updated_at, 'X'),
category: item.seo_keywords.split(','),
author: item.user_info.nickname,
})),
};
}View on GitHub (pinned to bed535e087)
Solutions
- Inspect the full return_msg in the thrown error to identify rate-limit vs maintenance vs schema change.
- If the body is HTML rather than JSON, the upstream is likely behind a WAF — verify with curl and adjust headers (User-Agent, Referer).
- Increase cache TTL / polling interval to avoid rate limits on the POST endpoint.
- Confirm the form fields (page, pub_time, isfromajax) still match what the site expects.
Example fix
// before
if (response.data.return_code !== '200') {
throw new Error(response.data.return_msg);
}
// after — guard the envelope shape before reading return_msg
if (!response.data || response.data.return_code !== '200') {
throw new Error(`niaogebiji today API error: ${response.data?.return_msg ?? 'unexpected response shape'}`);
} Defensive patterns
Strategy: try-catch
Type guard
const isTodayEnvelopeOk = (r: any): boolean => r?.data && typeof r.data === 'object' && r.data.return_code === '200' && Array.isArray(r.data.return_data);
Try / catch
try {
const response = await got({ method: 'post', url: '.../pc/bulletin/index', form: {...} });
if (!response.data || response.data.return_code !== '200')
throw new Error(`bulletin API: ${response.data?.return_msg ?? 'bad shape'}`);
} catch (e) {
// backoff — likely rate-limited POST endpoint or WAF HTML response
} Prevention
- POST endpoints are more rate-limit-prone — poll less often than GET routes.
- Validate response.data is an object before reading return_code.
- Send realistic headers (User-Agent, Referer) to avoid WAF HTML responses.
When it happens
Trigger: The bulletin endpoint returns return_code !== '200', or the got() response body is not the expected JSON shape (e.g. an HTML error page from a WAF/CDN), making response.data.return_code undefined and the comparison truthy in an unexpected way.
Common situations: Rate limiting on the POST endpoint; site maintenance; the form payload changed and the server rejects it; an edge proxy returns HTML on error so response.data is a string and return_msg is undefined.
Related errors
- ${response.return_msg}
- 文章列表获取失败,可能是被临时限制了访问,请稍后重试 ${JSON.stringify(resp.data)}
- 中国政府网搜索接口请求失败,错误代码:${response?.resultCode?.code ?? '未知'}
- 未获取到数据!
- Failed to get series data
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/06d6a2568ce8c609.
Report an issue: GitHub.