DIYgod/RSSHub · error · Error
成功获取数据对象,但未找到作品基本信息
Error message
成功获取数据对象,但未找到作品基本信息
What it means
The dehydrated React Query was found and its state.data was non-null, but state.data.work is missing. This is a shape-level mismatch: the API response object exists but does not contain the expected 'work' property that holds manga metadata (title, authors, summary, cover, episodes).
Source
Thrown at lib/routes/comic-walker/manga.ts:68
if (!nextDataText) {
throw new Error('无法解析页面 HTML 数据,可能触发了反爬策略或页面结构巨变');
}
const nextData = JSON.parse(nextDataText);
const queries = nextData.props?.pageProps?.dehydratedState?.queries || [];
const workQuery = queries.find((q: any) => q.queryKey?.includes('/api/contents/details/work') || (Array.isArray(q.queryKey) && q.queryKey.some((k: any) => typeof k === 'string' && k.includes('work'))));
if (!workQuery || !workQuery.state?.data) {
throw new Error('无法在 HTML 缓存中提取核心数据对象');
}
const data = workQuery.state.data;
const work = data.work;
if (!work) {
throw new Error('成功获取数据对象,但未找到作品基本信息');
}
const mangaTitle = work.title || $('title').text();
const mangaAuthor = work.authors?.map((author: any) => author.name).join(', ');
const mangaDescription = work.summary || '';
const coverImage = work.bookCover || work.thumbnail;
const firstEpisodes = getEpisodes(data.firstEpisodes);
const latestEpisodes = getEpisodes(data.latestEpisodes);
const extraEpisodes = getEpisodes(data.episodes);
const seenCodes = new Set<string>();
const allChapters = [...firstEpisodes, ...latestEpisodes, ...extraEpisodes]
.filter((ep) => {
if (ep?.code && !seenCodes.has(ep.code)) {
seenCodes.add(ep.code);
return true;
}View on GitHub (pinned to bed535e087)
Solutions
- Log the full data object to see its actual top-level keys.
- Tighten the queryKey matching to avoid accidentally matching a non-work query.
- Check if the API now nests work data under a different key (e.g., data.result.work or data.data.work).
- Verify the manga ID is valid by checking the API response status.
Example fix
// before
const data = workQuery.state.data;
const work = data.work;
if (!work) {
throw new Error('成功获取数据对象,但未找到作品基本信息');
}
// after — expose available keys
const data = workQuery.state.data;
const work = data.work;
if (!work) {
throw new Error(`Data object missing 'work' key. Available keys: ${Object.keys(data).join(', ')}`);
} Defensive patterns
Strategy: type-guard
Type guard
function hasWorkData(data: any): data is { work: { title: string; authors: any[]; summary: string } } {
return data != null && typeof data === 'object' && typeof data.work === 'object' && data.work != null;
} Prevention
- Tighten the queryKey matching to avoid selecting a non-work query that lacks the work field.
- Use a type guard to verify the data shape before accessing nested properties.
- Log Object.keys(data) when work is missing to quickly identify renamed fields.
When it happens
Trigger: workQuery.state.data is truthy but data.work is undefined or null. This can happen when the API response embeds work data under a different key, when the response represents an error state (e.g., { error: '...' }), or when the query resolved with partial data.
Common situations: The API response schema changed — 'work' was renamed or nested one level deeper; the manga was deleted and the API returns a soft-error object with status but no work field; a different query (e.g., a related-works query) was matched by the loose 'work' substring check and contains unrelated data.
Related errors
- 无法在 HTML 缓存中提取核心数据对象
- 无法解析页面 Props 数据
- 无法解析页面 HTML 数据,可能触发了反爬策略或页面结构巨变
- HTML 缓存中无章节!
- 无法解析页面数据,请检查漫画 ID 是否正确或页面结构是否变动
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/2f57f95dd2a536e6.
Report an issue: GitHub.