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

  1. Inspect the full return_msg in the thrown error to identify rate-limit vs maintenance vs schema change.
  2. If the body is HTML rather than JSON, the upstream is likely behind a WAF — verify with curl and adjust headers (User-Agent, Referer).
  3. Increase cache TTL / polling interval to avoid rate limits on the POST endpoint.
  4. 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

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


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/06d6a2568ce8c609. Report an issue: GitHub.