DIYgod/RSSHub · error · Error

中国政府网搜索接口请求失败,错误代码:${response?.resultCode?.code ?? '未知'}

Error message

中国政府网搜索接口请求失败,错误代码:${response?.resultCode?.code ?? '未知'}

What it means

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).

Source

Thrown at lib/routes/gov/zhengce/govall.ts:181

| pubmintimeYear, pubmintimeMonth |                    从某年某月                    |       单独使用月份参数无法只筛选月份       |
| pubmaxtimeYear, pubmaxtimeMonth |                    到某年某月                    |       单独使用月份参数无法只筛选月份       |
|              colid              |                       栏目                       |            上游新接口已不再支持            |`,
};

async function handler(ctx) {
    const advance = ctx.req.param('advance');
    const request = buildSearchRequest(advance);
    const link = buildSearchLink(request);
    const { data: response } = await got.post(searchApiUrl, {
        headers: {
            athenaAppKey: getAthenaAppKey(),
            athenaAppName: encodeURIComponent('国网搜索'),
        },
        json: request,
    });

    if (response?.resultCode?.code !== 200 || !Array.isArray(response?.result?.data?.middle?.list)) {
        throw new Error(`中国政府网搜索接口请求失败,错误代码:${response?.resultCode?.code ?? '未知'}`);
    }

    const list = response.result.data.middle.list.filter((item) => item.url).map((item) => normalizeSearchItem(item));

    const items = await Promise.all(
        list.map((item) =>
            cache.tryGet(item.link, async () => {
                let description = item.description;
                try {
                    const contentData = await got(item.link);
                    const content = load(contentData.data);
                    description = content('#UCAP-CONTENT, div.TRS_UEDITOR').first().html() || description;
                } catch {
                    // Keep the API summary when the article page is unavailable.
                }

                return {
                    ...item,

View on GitHub (pinned to bed535e087)

Solutions

  1. Retry after a short delay — transient backend errors are common on gov.cn search.
  2. 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.
  3. Verify the `searchApiUrl` forward hash has not changed.
  4. Open `https://sousuo.www.gov.cn/sousuo/search.shtml` in a browser, inspect network requests, and compare the POST payload and headers.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    const { data: response } = await got.post(searchApiUrl, { ... });
    if (response?.resultCode?.code !== 200 || !Array.isArray(response?.result?.data?.middle?.list)) {
        throw new Error(`中国政府网搜索接口请求失败,错误代码:${response?.resultCode?.code ?? '未知'}`);
    }
} catch (err) {
    // Distinguish network errors from API-level errors
    throw new Error(`gov.cn search failed: ${err instanceof Error ? err.message : String(err)}`);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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