DIYgod/RSSHub · error · Error

未获取到数据!

Error message

未获取到数据!

What it means

Thrown by the Miyoushe (米游社) 'followed timeline' route when the upstream API call to bbs-api.miyoushe.com/painter/wapi/timeline/list returns a response whose .data.data.list is falsy. It is a bare `throw new Error('未获取到数据!')` (Chinese for 'No data obtained'), not a typed RSSHub error, so it surfaces as a generic 500 rather than a structured error. The list is the array of posts from accounts the configured login follows; an empty/missing list is treated as a hard failure.

Source

Thrown at lib/routes/mihoyo/bbs/timeline.ts:63

    const page_size = ctx.req.query('limit') || '20';
    const searchParams = {
        gids: 2,
        page_size,
    };
    const link = 'https://www.miyoushe.com/ys/timeline';
    const url = 'https://bbs-api.miyoushe.com/painter/wapi/timeline/list';
    const response = await got({
        method: 'get',
        url,
        searchParams,
        headers: {
            Referer: link,
            Cookie: config.mihoyo.cookie,
        },
    });
    const list = response?.data?.data?.list;
    if (!list) {
        throw new Error('未获取到数据!');
    }
    const { nickname: username } = await cache.getUserFullInfo(ctx, '');
    const title = `米游社 - ${username} 的关注动态`;
    const items = list.map((e) => post2item(e));

    const data = {
        title,
        link,
        item: items,
    };
    return data;
}

View on GitHub (pinned to bed535e087)

Solutions

  1. Re-log into miyoushe.com in a browser, copy a fresh cookie string, and update the MIHOYO_COOKIE environment variable, then restart RSSHub.
  2. Confirm the configured account actually follows at least one user on miyoushe.com/ys/timeline (an account with no follows yields no list).
  3. Reproduce the exact request (curl with the same Cookie + Referer: https://www.miyoushe.com/ys/timeline and searchParams gids=2&page_size=20) and inspect the raw JSON to see whether the API returns an error code, a captcha, or an empty list.
  4. If the cookie is valid but risk-control blocks it, run RSSHub from a residential/IP in a region miyoushe tolerates, or supply additional cookie fields captured from a full browser session.

Example fix

// before
const list = response?.data?.data?.list;
if (!list) {
    throw new Error('未获取到数据!');
}

// after — surface the real upstream reason instead of a bare error
const list = response?.data?.data?.list;
if (!list) {
    const msg = response?.data?.message || response?.data?.data?.message || 'miyoushe returned no timeline list (check MIHOYO_COOKIE / risk-control / follows)';
    throw new Error(msg);
}
Defensive patterns

Strategy: validation

Validate before calling

// Before calling the timeline API, assert the cookie is configured and well-formed.
const cookie = config.mihoyo.cookie;
if (!cookie || !cookie.includes('=')) {
    throw new ConfigNotFoundError('MIHOYO_COOKIE is missing or malformed — re-log into miyoushe.com and set it.');
}

Type guard

// Narrow the upstream envelope before accessing .list
function isTimelineEnvelope(r: unknown): r is { data: { data: { list: unknown[] } } } {
    return !!r && typeof r === 'object'
        && Array.isArray((r as any)?.data?.data?.list);
}

Prevention

When it happens

Trigger: The handler sends a GET with the operator's MIHOYO_COOKIE and a Referer of miyoushe.com/ys/timeline. The error fires when: (a) the cookie is expired/invalid so the API replies with an error envelope lacking .data.list; (b) the logged-in account follows zero users (list genuinely empty/null); (c) miyoushe returns an anti-crawler/verification (geetest) challenge page instead of JSON; (d) the response shape changed and the nested path response.data.data.list no longer exists.

Common situations: Self-hosters who set MIHOYO_COOKIE once and never refresh it (cookies expire within days/weeks); a fresh deploy where the cookie env var was set but the account has no followed users; miyoushe tightening its risk-control so the same cookie that worked yesterday now triggers a captcha; the API contract shifting so the data nesting moves.

Related errors


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