DIYgod/RSSHub · error · Error
No threads found. The cookie may be expired or invalid. Plea
Error message
No threads found. The cookie may be expired or invalid. Please check your BAIDU_COOKIE.
What it means
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.
Source
Thrown at lib/routes/baidu/tieba/forum.tsx:64
}
}
return { text, images };
}
async function handler(ctx) {
const { kw, cid = '0', sortBy = 'created' } = ctx.req.param();
const isGood = ctx.req.path.includes('good');
const data = await getTiebaForumData({ kw, cid, isGood, sortBy });
if (data?.error_code && data.error_code !== '0' && data.error_code !== 0) {
throw new Error(`Tieba API error: ${data.error_msg || data.error_code}`);
}
const threadList = data?.thread_list || [];
if (threadList.length === 0) {
throw new Error('No threads found. The cookie may be expired or invalid. Please check your BAIDU_COOKIE.');
}
// Build author map from user_list
const userList: any[] = data?.user_list || [];
const authorMap = new Map<number, string>();
for (const user of userList) {
if (user.id) {
authorMap.set(Number(user.id), user.name_show || user.name || '');
}
}
const list = threadList.map((thread) => {
// Prefer first_post_content (richer), fall back to abstract
const { text: content, images } = extractContent(thread.first_post_content || thread.abstract || []);
const timestamp = Number(thread.create_time || 0);
const pubDate = timestamp > 0 ? timezone(new Date(timestamp * 1000), 8) : undefined;
View on GitHub (pinned to bed535e087)
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.
Example fix
// before // BAIDU_COOKIE unset or stale // after export BAIDU_COOKIE='BIDUSSDBID=...; STOKEN=...; ...'
Defensive patterns
Strategy: validation
Validate before calling
function hasTiebaThreads(data: any): boolean {
return Array.isArray(data?.thread_list) && data.thread_list.length > 0;
}
if (!hasTiebaThreads(data)) {
throw new Error('BAIDU_COOKIE may be expired - thread_list is empty');
} Type guard
const looksAuthenticated = (d: any): boolean => Array.isArray(d?.thread_list) && d.thread_list.length > 0;
Try / catch
try {
return await handler(ctx);
} catch (e) {
if (e instanceof Error && /cookie may be expired/i.test(e.message)) {
// surface a 503 + clear guidance instead of a generic 500
ctx.throw(503, 'Refresh BAIDU_COOKIE');
}
throw e;
} Prevention
- 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.
When it happens
Trigger: getTiebaForumData returns { error_code: 0, thread_list: [] } - the call succeeds but produces no threads, the canonical signature of an unauthenticated Tieba API response.
Common situations: 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.
Related errors
- Tieba API error: ${data.error_msg || data.error_code}
- No post replies found. The post may not exist or the cookie
- No user posts found. The page structure may have changed or
- 暂时无法获取快递信息,请稍后重试...
- 缺少 Medium 用户 ${user} 登录后的 Cookie 值
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/6a87108513e7f2c9.
Report an issue: GitHub.