{"record":{"id":"5a1d78b0e232cbaa","repo":"DIYgod/RSSHub","slug":"response-resultcode-code","errorCode":null,"errorMessage":"中国政府网搜索接口请求失败，错误代码：${response?.resultCode?.code ?? '未知'}","messagePattern":"中国政府网搜索接口请求失败，错误代码：(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/gov/zhengce/govall.ts","lineNumber":181,"sourceCode":"| pubmintimeYear, pubmintimeMonth |                    从某年某月                    |       单独使用月份参数无法只筛选月份       |\n| pubmaxtimeYear, pubmaxtimeMonth |                    到某年某月                    |       单独使用月份参数无法只筛选月份       |\n|              colid              |                       栏目                       |            上游新接口已不再支持            |`,\n};\n\nasync function handler(ctx) {\n    const advance = ctx.req.param('advance');\n    const request = buildSearchRequest(advance);\n    const link = buildSearchLink(request);\n    const { data: response } = await got.post(searchApiUrl, {\n        headers: {\n            athenaAppKey: getAthenaAppKey(),\n            athenaAppName: encodeURIComponent('国网搜索'),\n        },\n        json: request,\n    });\n\n    if (response?.resultCode?.code !== 200 || !Array.isArray(response?.result?.data?.middle?.list)) {\n        throw new Error(`中国政府网搜索接口请求失败，错误代码：${response?.resultCode?.code ?? '未知'}`);\n    }\n\n    const list = response.result.data.middle.list.filter((item) => item.url).map((item) => normalizeSearchItem(item));\n\n    const items = await Promise.all(\n        list.map((item) =>\n            cache.tryGet(item.link, async () => {\n                let description = item.description;\n                try {\n                    const contentData = await got(item.link);\n                    const content = load(contentData.data);\n                    description = content('#UCAP-CONTENT, div.TRS_UEDITOR').first().html() || description;\n                } catch {\n                    // Keep the API summary when the article page is unavailable.\n                }\n\n                return {\n                    ...item,","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/gov/zhengce/govall.ts#L163-L199","documentation":"Thrown by the gov.cn search aggregator route when the upstream Athena search API response does not have `resultCode.code === 200` or when `result.data.middle.list` is not an array. This indicates the gov.cn search backend rejected the request or returned an unexpected schema. The error message includes the numeric code from the response (or '未知' if absent).","triggerScenarios":"The POST to `sousuoht.www.gov.cn/athena/forward/...` fails because the RSA-encrypted `athenaAppKey` is rejected, the search backend is down, the API schema changed, or rate limiting returns a non-200 result code.","commonSituations":"The embedded athena credential/public key changed on the gov.cn side (they rotate these), the API endpoint was updated, or transient backend errors. The route hardcodes the credential and key in the source, so a rotation upstream breaks all requests.","solutions":["Retry after a short delay — transient backend errors are common on gov.cn search.","If persistent, check whether the `athenaAppCredential` and `athenaPublicKey` constants in the source still match the values embedded in the live `sousuo.www.gov.cn` search page JavaScript; extract fresh values if they rotated.","Verify the `searchApiUrl` forward hash has not changed.","Open `https://sousuo.www.gov.cn/sousuo/search.shtml` in a browser, inspect network requests, and compare the POST payload and headers."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    const { data: response } = await got.post(searchApiUrl, { ... });\n    if (response?.resultCode?.code !== 200 || !Array.isArray(response?.result?.data?.middle?.list)) {\n        throw new Error(`中国政府网搜索接口请求失败，错误代码：${response?.resultCode?.code ?? '未知'}`);\n    }\n} catch (err) {\n    // Distinguish network errors from API-level errors\n    throw new Error(`gov.cn search failed: ${err instanceof Error ? err.message : String(err)}`);\n}","preventionTips":["Periodically verify the hardcoded `athenaAppCredential` and `athenaPublicKey` against the live search page.","Cache search results to reduce dependency on the upstream API.","Log the full response body on failure for diagnosis without exposing it to end users.","Monitor for API endpoint changes on gov.cn."],"tags":["network","upstream","api","government","config-drift"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}