DIYgod/RSSHub · error · Error
Invalid response
Error message
Invalid response
What it means
Thrown by the Douyu live room route when the `/betard/<id>` API response does not contain a `room` property. The betard API returns the room metadata as JSON; if the room doesn't exist or the API format changed, the `room` field is absent. This is a plain Error thrown inside a try-catch block that also catches network errors.
Source
Thrown at lib/routes/douyu/room.ts:37
source: ['www.douyu.com/:id', 'www.douyu.com/'],
},
],
name: '直播间开播',
maintainers: ['DIYgod', 'ChaosTong'],
handler,
};
async function handler(ctx) {
const id = ctx.req.param('id');
let data;
let item;
let room_thumb;
try {
const response = await ofetch(`https://www.douyu.com/betard/${id}`);
if (!response.room) {
throw new Error('Invalid response');
}
data = response.room;
room_thumb = data.room_pic;
if (data.show_status === 1) {
item = [
{
title: `${data.videoLoop === 1 ? '视频轮播' : '开播'}: ${data.room_name}`,
pubDate: new Date(data.show_time * 1000).toUTCString(),
guid: data.show_time,
link: `https://www.douyu.com/${id}`,
description: `<img src="${room_thumb}">`,
},
];
}
// make a fallback to the old api
} catch {View on GitHub (pinned to bed535e087)
Solutions
- Verify the room ID by visiting https://www.douyu.com/<id> in a browser.
- Find the correct ID from the streamer's Douyu page URL.
- If the API structure changed, check for RSSHub updates.
Example fix
// before
if (!response.room) {
throw new Error('Invalid response');
}
// after
if (!response.room) {
throw new Error(`Invalid response from Douyu betard API for room ${id}. The room may not exist or the API format has changed.`);
} Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate the Douyu room ID
function isValidDouyuRoomId(id: string): boolean {
return /^\d+$/.test(id) || /^[a-zA-Z0-9]+$/.test(id);
}
// Pre-flight check: verify the room exists
async function checkDouyuRoom(id: string): Promise<boolean> {
try {
const resp = await fetch(`https://www.douyu.com/betard/${id}`);
const data = await resp.json();
return !!data.room;
} catch {
return false;
}
} Type guard
interface DouyuBetardResponse {
room?: {
room_name: string;
show_status: number;
room_pic: string;
};
}
function isValidDouyuResponse(data: unknown): data is DouyuBetardResponse {
return typeof data === 'object' && data !== null && typeof (data as any).room === 'object';
} Try / catch
try {
const feed = await fetch(`${rsshubUrl}/douyu/room/${id}`);
} catch (e) {
if (e.message.includes('Invalid response')) {
console.error(`Room ${id} may not exist or the Douyu API changed.`);
}
throw e;
} Prevention
- Verify the room ID by visiting https://www.douyu.com/<id> in a browser.
- Note that some Douyu rooms use alphabetic IDs, not just numeric.
- Check for RSSHub updates if the betard API structure changes.
When it happens
Trigger: The room ID doesn't exist (no streamer with that ID); the betard API returned an error object without a room field; the API endpoint structure changed; the room ID contains special characters that weren't properly handled.
Common situations: User enters an incorrect or expired room ID; Douyu restructured the betard API; the room was permanently closed by Douyu.
Related errors
- Status code ${renderData.status_code}
- message ?? code
- message ?? code
- Got error code ${data.code} while fetching: ${data.message}
- message ?? code
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/48fb1f0432285697.
Report an issue: GitHub.