DIYgod/RSSHub · error · Error

文章列表不存在或为空

Error message

文章列表不存在或为空

What it means

The dedao (得到) articles route POSTs to the pageTurning API and expects a JSON response containing an article_list array. If the response is falsy or lacks article_list, the route cannot extract any articles. This typically indicates the course ID (pid) is invalid, the course has no free articles, or the API response shape changed.

Source

Thrown at lib/routes/dedao/articles.ts:104

    const response = await got.post('https://m.igetget.com/share/api/course/free/pageTurning', {
        json: {
            chapter_id: 0,
            count: 5,
            max_id,
            max_order_num: 0,
            pid: Number(id),
            ptype: 24,
            reverse: true,
            since_id: 0,
            since_order_num: 0,
        },
        headers,
    });

    const data = JSON.parse(response.body);
    if (!data || !data.article_list) {
        throw new Error('文章列表不存在或为空');
    }

    const articles = data.article_list;

    const items = await Promise.all(
        articles.map((article) => {
            const postUrl = `https://m.igetget.com/share/course/article/article_id/${article.id}`;
            const postTitle = article.title;
            const postTime = new Date(article.publish_time * 1000).toUTCString();

            return cache.tryGet<any>(postUrl, async () => {
                const detailResponse = await got.get(postUrl, { headers });
                const $ = load(detailResponse.body);

                const scriptTag = $('script')
                    .filter((_, el) => $(el).text()?.includes('window.__INITIAL_STATE__'))
                    .text();

View on GitHub (pinned to bed535e087)

Solutions

  1. Verify the course ID by visiting https://m.igetget.com/share/course/free/detail?id=<id> in a browser.
  2. Log the full response body to see the actual API response and any error message.
  3. Check if the ptype parameter needs to be dynamic based on the course type.
  4. Update the API endpoint or headers if the igetget API has changed.

Example fix

// before
const data = JSON.parse(response.body);
if (!data || !data.article_list) {
    throw new Error('文章列表不存在或为空');
}

// after — expose the actual API response for diagnosis
const data = JSON.parse(response.body);
if (!data || !data.article_list) {
    throw new Error(`文章列表不存在或为空 (course id: ${id}, response: ${JSON.stringify(data).slice(0, 200)})`);
}
Defensive patterns

Strategy: validation

Validate before calling

const data = JSON.parse(response.body);
if (response.statusCode !== 200 || !data) {
    throw new Error(`Dedao API returned status ${response.statusCode}`);
}
if (!data.article_list) {
    throw new Error(`No article_list in response for course ${id}. Response keys: ${Object.keys(data).join(', ')}`);
}

Type guard

function hasArticleList(data: any): data is { article_list: Array<{ id: string; title: string; publish_time: number }> } {
    return data != null && Array.isArray(data.article_list) && data.article_list.length > 0;
}

Try / catch

try {
    const data = JSON.parse(response.body);
    if (!data?.article_list) throw new Error('No article_list');
} catch (e) {
    if (e instanceof SyntaxError) {
        throw new Error('Dedao API returned non-JSON response');
    }
    throw e;
}

Prevention

When it happens

Trigger: got.post succeeds but JSON.parse(response.body) yields an object without article_list. The API may return { status: 'error', msg: '...' } or { article_list: null } for invalid course IDs. The ptype: 24 parameter is hardcoded and may not match all course types.

Common situations: The id parameter (course ID) is wrong or refers to a paid-only course with no free articles; the igetget API changed its response format or endpoint; the hardcoded ptype: 24 does not match the course type of the requested ID; the API requires authentication that is no longer optional.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/71aa07c6995de15d. Report an issue: GitHub.