{"record":{"id":"8b23f220fbdc6541","repo":"DIYgod/RSSHub","slug":"expected-datakey-property-not-found-in-pagepr","errorCode":null,"errorMessage":"Expected '${dataKey}' property not found in pageProps for category: ${category || 'home'}","messagePattern":"Expected '(.+?)' property not found in pageProps for category: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/hupu/index.ts","lineNumber":75,"sourceCode":"        if (!Object.hasOwn(categories, c)) {\n            throw new Error('Invalid category. Valid options are: ' + Object.keys(categories).filter(Boolean).join(', '));\n        }\n        const category = c as keyof typeof categories;\n\n        const rootUrl = 'https://m.hupu.com';\n        const currentUrl = `${rootUrl}/${category}`;\n\n        const response = await got({\n            method: 'get',\n            url: currentUrl,\n        });\n\n        const data = extractNextData<HupuApiResponse>(response.data, currentUrl);\n        const { pageProps } = data.props;\n\n        const dataKey = categories[category].data;\n        if (!Object.hasOwn(pageProps, dataKey)) {\n            throw new Error(`Expected '${dataKey}' property not found in pageProps for category: ${category || 'home'}`);\n        }\n\n        const rawDataArray: Array<HomePostItem | NewsDataItem> = (() => {\n            const data = (pageProps as any)[dataKey];\n            return Array.isArray(data) ? data : [];\n        })();\n\n        let items: DataItem[] = rawDataArray.map((item) =>\n            isHomePostItem(item)\n                ? ({\n                      title: item.title,\n                      link: item.url.replace(/bbs\\.hupu.com/, 'm.hupu.com/bbs'),\n                      guid: item.tid,\n                      category: item.label ? [item.label] : undefined,\n                  } satisfies DataItem)\n                : ({\n                      title: item.title,\n                      pubDate: timezone(parseDate(item.publishTime), 8),","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/hupu/index.ts#L57-L93","documentation":"Thrown by the Hupu mobile route after fetching the page when the parsed `__NEXT_DATA__` JSON's `pageProps` object does not contain the expected data property key. Each category in the `categories` map declares a `data` field (`newsData` for nba/cba, `news` for soccer, `res` for home) that names the property under `pageProps` holding the article array. If Hupu changes their Next.js page structure, this key may not exist.","triggerScenarios":"The Hupu mobile site was updated and the Next.js `pageProps` no longer uses the expected property name (e.g. renamed `newsData` to something else), or the page returned an error/blocked response that still contained `__NEXT_DATA__` but with a different shape.","commonSituations":"Hupu ships a frontend update changing the pageProps schema, anti-bot measures serve a challenge page with a different `__NEXT_DATA__` structure, or a category-specific page has a different layout than expected.","solutions":["Open `https://m.hupu.com/<category>` in a browser, view page source, find `<script id=\"__NEXT_DATA__\">`, and check whether the expected property (`newsData`, `news`, or `res`) exists under `props.pageProps`.","If the property was renamed, update the `data` field in the `categories` object to match.","If the page structure changed more broadly, update the `extractNextData` and item parsing logic.","Retry to rule out a transient anti-bot challenge page."],"exampleFix":"// before (category maps to a property name that no longer exists)\nconst categories = {\n    nba: { title: 'NBA', data: 'newsData' },\n    ...\n};\n\n// after (updated to match new pageProps key)\nconst categories = {\n    nba: { title: 'NBA', data: 'newsDataV2' },\n    ...\n};","handlingStrategy":"try-catch","validationCode":"// Cannot pre-validate upstream page structure; can only validate the response shape after fetching.\nfunction hasExpectedPageProps(pageProps: unknown, dataKey: string): boolean {\n    return typeof pageProps === 'object' && pageProps !== null && dataKey in pageProps;\n}","typeGuard":"function hasDataKey(pageProps: Record<string, unknown>, dataKey: string): boolean {\n    return Object.hasOwn(pageProps, dataKey);\n}","tryCatchPattern":"try {\n    const data = extractNextData<HupuApiResponse>(response.data, currentUrl);\n    const { pageProps } = data.props;\n    if (!Object.hasOwn(pageProps, dataKey)) {\n        throw new Error(`Expected '${dataKey}' not found — upstream schema may have changed`);\n    }\n} catch (err) {\n    // Distinguish parsing failure from schema mismatch\n    throw new Error(`Hupu page parse failed for ${currentUrl}: ${err instanceof Error ? err.message : String(err)}`);\n}","preventionTips":["Monitor the Hupu mobile site for frontend updates that change pageProps structure.","Cache successful parses to reduce exposure to transient anti-bot pages.","Log the actual pageProps keys on mismatch for faster diagnosis."],"tags":["upstream","parsing","schema-change","rsshub","bbs"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}