{"record":{"id":"06d6a2568ce8c609","repo":"DIYgod/RSSHub","slug":"response-data-return-msg","errorCode":null,"errorMessage":"${response.data.return_msg}","messagePattern":"\\$\\{response\\.data\\.return_msg\\}","errorType":"exception","errorClass":"Error","httpStatus":503,"severity":"error","filePath":"lib/routes/niaogebiji/today.ts","lineNumber":42,"sourceCode":"    name: '今日事',\n    maintainers: ['KotoriK'],\n    handler,\n    url: 'niaogebiji.com/',\n};\n\nasync function handler() {\n    const response = await got({\n        method: 'post',\n        url: 'https://www.niaogebiji.com/pc/bulletin/index',\n        form: {\n            page: 1,\n            pub_time: '',\n            isfromajax: 1,\n        },\n    });\n\n    if (response.data.return_code !== '200') {\n        throw new Error(response.data.return_msg);\n    }\n\n    const data = response.data.return_data;\n\n    return {\n        title: '鸟哥笔记-今日事',\n        link: 'https://www.niaogebiji.com/bulletin',\n        item: data.map((item) => ({\n            title: item.title,\n            description: item.content,\n            link: item.url,\n            pubDate: parseDate(item.pub_time, 'X'),\n            updated: parseDate(item.updated_at, 'X'),\n            category: item.seo_keywords.split(','),\n            author: item.user_info.nickname,\n        })),\n    };\n}","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/niaogebiji/today.ts#L24-L60","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nif (response.data.return_code !== '200') {\n    throw new Error(response.data.return_msg);\n}\n\n// after — guard the envelope shape before reading return_msg\nif (!response.data || response.data.return_code !== '200') {\n    throw new Error(`niaogebiji today API error: ${response.data?.return_msg ?? 'unexpected response shape'}`);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isTodayEnvelopeOk = (r: any): boolean =>\n  r?.data && typeof r.data === 'object' && r.data.return_code === '200' && Array.isArray(r.data.return_data);","tryCatchPattern":"try {\n  const response = await got({ method: 'post', url: '.../pc/bulletin/index', form: {...} });\n  if (!response.data || response.data.return_code !== '200')\n    throw new Error(`bulletin API: ${response.data?.return_msg ?? 'bad shape'}`);\n} catch (e) {\n  // backoff — likely rate-limited POST endpoint or WAF HTML response\n}","preventionTips":["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."],"tags":["api","upstream","rate-limit","niaogebiji","envelope"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}