jackwener/OpenCLI · error · Error

帖子不存在或已被删除

Error message

帖子不存在或已被删除

What it means

After the error-info check passes (code 200), the library expects data.props.pageProps.detail.thread to hold the thread object. When it is absent the thread effectively does not exist or was deleted, so this Error is thrown instead of returning partial data.

Source

Thrown at clis/hupu/detail.js:40

            help: '是否包含热门回复'
        }
    ],
    columns: ['title', 'author', 'content', 'replies', 'lights', 'url'],
    func: async (page, kwargs) => {
        const { tid, replies: includeReplies = false } = kwargs;
        const url = getHupuThreadUrl(tid).replace(/-1\.html$/, '.html');
        const data = await readHupuNextData(page, url, 'Read Hupu thread detail', {
            expectedTid: String(tid),
        });
        // 检查错误信息(只有当code不是200时才报错)
        const errorInfo = data.props.pageProps.detail_error_info;
        if (errorInfo && errorInfo.code !== 200) {
            throw new Error(`帖子访问失败: ${errorInfo.message} (code: ${errorInfo.code})`);
        }
        // 获取帖子信息
        const thread = data.props.pageProps.detail?.thread;
        if (!thread) {
            throw new Error('帖子不存在或已被删除');
        }
        const authorName = thread.author?.puname || '未知作者';
        const content = stripHtml(thread.content);
        const contentPreview = content.length > 300 ? content.substring(0, 300) + '...' : content;
        // 构建结果
        const result = {
            title: thread.title,
            author: authorName,
            content: contentPreview,
            replies: thread.replies || 0,
            lights: thread.lights || 0,
            url: `https://bbs.hupu.com/${tid}.html`
        };
        // 如果需要包含回复,添加回复信息到内容中
        if (includeReplies) {
            const replyList = data.props.pageProps.detail?.lights || [];
            const topReplies = replyList.slice(0, 3);
            if (topReplies.length > 0) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Confirm the thread still exists by opening its URL in a browser
  2. Retry after a short delay — freshly deleted or under-review posts may transiently lack the thread payload
  3. If this happens for all threads, inspect __NEXT_DATA__ in a browser and update the detail/thread extraction path in clis/hupu/detail.js

Example fix

// before
const thread = data.props.pageProps.detail?.thread;
// after
const thread = data.props.pageProps.detail?.thread
  ?? data.props.pageProps.threadInfo?.thread;
if (!thread) throw new Error('帖子不存在或已被删除');
Defensive patterns

Strategy: type-guard

Type guard

function hasThread(nextData) {
  return Boolean(nextData?.props?.pageProps?.detail?.thread);
}

Try / catch

try {
  const d = await hupuDetail(tid);
} catch (e) {
  if (e.message === '帖子不存在或已被删除') return null;
  throw e;
}

Prevention

When it happens

Trigger: detail_error_info.code === 200 (no explicit error) but pageProps.detail.thread is undefined — the thread payload is missing entirely from __NEXT_DATA__.

Common situations: Recently deleted threads where the error code still says 200; soft-removed/审核中 posts; Hupu A/B layout changes moving thread data to a different prop path; cached pages whose data was pruned.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/0b03aad13b57ec02. Report an issue: GitHub.