DIYgod/RSSHub · error · Error
Expected '${dataKey}' property not found in pageProps for ca
Error message
Expected '${dataKey}' property not found in pageProps for category: ${category || 'home'} What it means
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.
Source
Thrown at lib/routes/hupu/index.ts:75
if (!Object.hasOwn(categories, c)) {
throw new Error('Invalid category. Valid options are: ' + Object.keys(categories).filter(Boolean).join(', '));
}
const category = c as keyof typeof categories;
const rootUrl = 'https://m.hupu.com';
const currentUrl = `${rootUrl}/${category}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const data = extractNextData<HupuApiResponse>(response.data, currentUrl);
const { pageProps } = data.props;
const dataKey = categories[category].data;
if (!Object.hasOwn(pageProps, dataKey)) {
throw new Error(`Expected '${dataKey}' property not found in pageProps for category: ${category || 'home'}`);
}
const rawDataArray: Array<HomePostItem | NewsDataItem> = (() => {
const data = (pageProps as any)[dataKey];
return Array.isArray(data) ? data : [];
})();
let items: DataItem[] = rawDataArray.map((item) =>
isHomePostItem(item)
? ({
title: item.title,
link: item.url.replace(/bbs\.hupu.com/, 'm.hupu.com/bbs'),
guid: item.tid,
category: item.label ? [item.label] : undefined,
} satisfies DataItem)
: ({
title: item.title,
pubDate: timezone(parseDate(item.publishTime), 8),View on GitHub (pinned to bed535e087)
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.
Example fix
// before (category maps to a property name that no longer exists)
const categories = {
nba: { title: 'NBA', data: 'newsData' },
...
};
// after (updated to match new pageProps key)
const categories = {
nba: { title: 'NBA', data: 'newsDataV2' },
...
}; Defensive patterns
Strategy: try-catch
Validate before calling
// Cannot pre-validate upstream page structure; can only validate the response shape after fetching.
function hasExpectedPageProps(pageProps: unknown, dataKey: string): boolean {
return typeof pageProps === 'object' && pageProps !== null && dataKey in pageProps;
} Type guard
function hasDataKey(pageProps: Record<string, unknown>, dataKey: string): boolean {
return Object.hasOwn(pageProps, dataKey);
} Try / catch
try {
const data = extractNextData<HupuApiResponse>(response.data, currentUrl);
const { pageProps } = data.props;
if (!Object.hasOwn(pageProps, dataKey)) {
throw new Error(`Expected '${dataKey}' not found — upstream schema may have changed`);
}
} catch (err) {
// Distinguish parsing failure from schema mismatch
throw new Error(`Hupu page parse failed for ${currentUrl}: ${err instanceof Error ? err.message : String(err)}`);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to find __NEXT_DATA__ script tag in page${url ? `: ${
- Failed to parse __NEXT_DATA__ JSON: ${error instanceof Error
- Failed to extract Algolia credentials from iapp.org
- Unknown type: ${x}
- Invalid category. Valid options are: ${Object.keys(categorie
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/8b23f220fbdc6541.
Report an issue: GitHub.