{"record":{"id":"6a87108513e7f2c9","repo":"DIYgod/RSSHub","slug":"no-threads-found-the-cookie-may-be-expired-or-inv","errorCode":null,"errorMessage":"No threads found. The cookie may be expired or invalid. Please check your BAIDU_COOKIE.","messagePattern":"No threads found\\. The cookie may be expired or invalid\\. Please check your BAIDU_COOKIE\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/baidu/tieba/forum.tsx","lineNumber":64,"sourceCode":"        }\n    }\n    return { text, images };\n}\n\nasync function handler(ctx) {\n    const { kw, cid = '0', sortBy = 'created' } = ctx.req.param();\n    const isGood = ctx.req.path.includes('good');\n\n    const data = await getTiebaForumData({ kw, cid, isGood, sortBy });\n\n    if (data?.error_code && data.error_code !== '0' && data.error_code !== 0) {\n        throw new Error(`Tieba API error: ${data.error_msg || data.error_code}`);\n    }\n\n    const threadList = data?.thread_list || [];\n\n    if (threadList.length === 0) {\n        throw new Error('No threads found. The cookie may be expired or invalid. Please check your BAIDU_COOKIE.');\n    }\n\n    // Build author map from user_list\n    const userList: any[] = data?.user_list || [];\n    const authorMap = new Map<number, string>();\n    for (const user of userList) {\n        if (user.id) {\n            authorMap.set(Number(user.id), user.name_show || user.name || '');\n        }\n    }\n\n    const list = threadList.map((thread) => {\n        // Prefer first_post_content (richer), fall back to abstract\n        const { text: content, images } = extractContent(thread.first_post_content || thread.abstract || []);\n\n        const timestamp = Number(thread.create_time || 0);\n        const pubDate = timestamp > 0 ? timezone(new Date(timestamp * 1000), 8) : undefined;\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/baidu/tieba/forum.tsx#L46-L82","documentation":"After passing the error_code check, the Tieba forum route requires a non-empty thread_list. An empty list throws an Error explicitly blaming an expired or invalid BAIDU_COOKIE, because in practice the API returns 200 with an empty list when the session is no longer authenticated.","triggerScenarios":"getTiebaForumData returns { error_code: 0, thread_list: [] } - the call succeeds but produces no threads, the canonical signature of an unauthenticated Tieba API response.","commonSituations":"BAIDU_COOKIE missing entirely, expired, or copied without the key BIDUSSDBID/Cookie fields; the forum genuinely has no threads (rare); cookie set for a different Baidu subdomain.","solutions":["Set a fresh BAIDU_COOKIE env var containing the full cookie string copied from a logged-in tieba.baidu.com session.","Confirm the cookie includes the BIDUSSDBID / STOKEN login cookies, not just tracking cookies.","Verify the forum (kw) actually has public threads in a browser while logged in."],"exampleFix":"// before\n// BAIDU_COOKIE unset or stale\n// after\nexport BAIDU_COOKIE='BIDUSSDBID=...; STOKEN=...; ...'","handlingStrategy":"validation","validationCode":"function hasTiebaThreads(data: any): boolean {\n  return Array.isArray(data?.thread_list) && data.thread_list.length > 0;\n}\nif (!hasTiebaThreads(data)) {\n  throw new Error('BAIDU_COOKIE may be expired - thread_list is empty');\n}","typeGuard":"const looksAuthenticated = (d: any): boolean =>\n  Array.isArray(d?.thread_list) && d.thread_list.length > 0;","tryCatchPattern":"try {\n  return await handler(ctx);\n} catch (e) {\n  if (e instanceof Error && /cookie may be expired/i.test(e.message)) {\n    // surface a 503 + clear guidance instead of a generic 500\n    ctx.throw(503, 'Refresh BAIDU_COOKIE');\n  }\n  throw e;\n}","preventionTips":["Validate BAIDU_COOKIE is set and includes BIDUSSDBID before deploying the route.","Refresh the cookie on a schedule (it expires periodically).","Treat 'thread_list empty' as an auth signal, not a content signal."],"tags":["baidu-tieba","cookie","auth","rss-route"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}