DIYgod/RSSHub · error · Error
countResponse.data.errors[0].message
Error message
countResponse.data.errors[0].message
What it means
Thrown by the lkong (龙空) forum thread route when the countReplies API call returns a response containing an errors array. The route re-throws the API's own error message verbatim (countResponse.data.errors[0].message), so the actual text is dynamic and depends on what the lkong API reports — e.g. 'thread not found', 'permission denied', '参数错误'.
Source
Thrown at lib/routes/lkong/thread.tsx:42
maintainers: ['nczitzk', 'ma6254'],
handler,
};
async function handler(ctx) {
const id = ctx.req.param('id');
const rootUrl = 'https://www.lkong.com';
const apiUrl = 'https://api.lkong.com/api';
const currentUrl = `${rootUrl}/thread/${id}`;
const countResponse = await got({
method: 'post',
url: apiUrl,
json: countReplies(id),
});
if (countResponse.data.errors) {
throw new Error(countResponse.data.errors[0].message);
}
const response = await got({
method: 'post',
url: apiUrl,
json: viewThread(id, Math.ceil(countResponse.data.data.thread.replies / 20)),
});
const items = response.data.data.posts.map((item) => ({
guid: item.pid,
author: item.user.name,
title: `#${item.lou} ${item.user.name}`,
link: `${rootUrl}/thread/${id}?pid=${item.pid}`,
pubDate: parseDate(item.dateline),
description:
(item.quote ? renderToString(<LkongQuote target={`${rootUrl}/thread/${id}?pid=${item.quote.pid}`} author={item.quote.author.name} content={renderContent(JSON.parse(item.quote.content))} />) : '') +
renderContent(JSON.parse(item.content)),
}));View on GitHub (pinned to bed535e087)
Solutions
- Confirm the thread ID by opening https://www.lkong.com/thread/{id} in a browser.
- Inspect the actual errors[0].message text — it comes directly from lkong and will indicate the specific problem.
- If the API changed its envelope, update the error-detection condition (e.g. check status code instead of an errors field).
- Guard against errors[0] being undefined to avoid a secondary TypeError.
Example fix
// before
if (countResponse.data.errors) {
throw new Error(countResponse.data.errors[0].message);
}
// after — defensive access + context
if (countResponse.data.errors?.length) {
throw new Error(`lkong API error for thread ${id}: ${countResponse.data.errors[0].message}`);
} Defensive patterns
Strategy: try-catch
Validate before calling
const id = ctx.req.param('id');
if (!/^\d+$/.test(id)) {
throw new InvalidParameterError(`Thread id must be numeric, got '${id}'`);
} Type guard
function hasLkongErrors(d: unknown): d is { errors: Array<{ message: string }> } {
return typeof d === 'object' && d !== null && 'errors' in d && Array.isArray((d as any).errors) && (d as any).errors.length > 0;
} Try / catch
try {
const countResponse = await got({ method: 'post', url: apiUrl, json: countReplies(id) });
if (hasLkongErrors(countResponse.data)) {
throw new Error(`lkong thread ${id}: ${countResponse.data.errors[0]?.message ?? 'unknown API error'}`);
}
} catch (e) {
throw new Error(`Failed to load lkong thread ${id}: ${(e as Error).message}`, { cause: e });
} Prevention
- Validate the thread id is numeric before the API call.
- Defensively access errors[0]?.message to avoid a secondary TypeError when the array is empty.
- Surface the API's own error text — it indicates the specific problem (not found, permissions, etc.).
- If the API envelope changes, update the error-detection predicate.
When it happens
Trigger: Requesting /lkong/thread/:id with a nonexistent, deleted, or admin-only thread id. The lkong API returns an errors array for invalid auth, bad thread id, or server-side problems. Also possible if the API envelope changed and a legitimate response now contains an 'errors' field for warnings.
Common situations: Thread ID is mistyped or copied incompletely (lkong IDs are long numerics). The thread was deleted by moderators. The API requires authentication/cookies that the route does not provide. The API is under maintenance and returns a generic error.
Related errors
- resErrorText
- response.msg
- Bad category. See <a href="https://docs.rsshub.app/routes/bb
- Douban 返回数据结构异常,可能触发反爬或限频。${details ? `上游信息:${details}` : ''
- Douban 返回空数据,可能触发反爬或限频。请稍后重试。
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/da01cb4abd92c0bb.
Report an issue: GitHub.