DIYgod/RSSHub · error · ConfigNotFoundError

Medium 用户 ${user} 的 Cookie 无效或已过期

Error message

Medium 用户 ${user} 的 Cookie 无效或已过期

What it means

ConfigNotFoundError thrown by the 'for-you' route when getWebInlineRecommendedFeedQuery returns falsy despite a cookie being present. The cookie is configured but Medium's recommendation API rejected it as invalid/expired — same pattern as 364.

Source

Thrown at lib/routes/medium/for-you.ts:47

    description: `::: warning
Personalized recommendations require the cookie value after logging in, so only self-hosting is supported. See the configuration module on the deployment page for details.
:::`,
};

async function handler(ctx) {
    const user = ctx.req.param('user');

    const cookie = config.medium.cookies[user];
    if (cookie === undefined) {
        throw new ConfigNotFoundError(`缺少 Medium 用户 ${user} 登录后的 Cookie 值`);
    }

    const posts = await getWebInlineRecommendedFeedQuery(user, cookie);
    ctx.set('json', posts);

    if (!posts) {
        // login failed
        throw new ConfigNotFoundError(`Medium 用户 ${user} 的 Cookie 无效或已过期`);
    }

    const urls = posts.items.map((data) => data.post.mediumUrl);

    const parsedArticles = await Promise.all(urls.map((url) => parseArticle(ctx, url)));

    return {
        title: `${user} Medium For You`,
        link: 'https://medium.com/',
        item: parsedArticles,
    };
}

View on GitHub (pinned to bed535e087)

Solutions

  1. Re-authenticate on medium.com and copy the fresh Cookie header into MEDIUM_COOKIES.
  2. Ensure the sid and cf_obc cookies are included.
  3. Restart RSSHub after updating config.
  4. Retry with a new Medium account if the session keeps expiring immediately.

Example fix

// before
MEDIUM_COOKIES=johndoe=stale_sid

// after
MEDIUM_COOKIES=johndoe=sid%3A1%3A...fresh...
Defensive patterns

Strategy: try-catch

Try / catch

try {
    const posts = await getWebInlineRecommendedFeedQuery(user, cookie);
    if (!posts) throw new ConfigNotFoundError('Cookie invalid/expired');
} catch (e) { /* surface as a config/cookie alert */ throw e; }

Prevention

When it happens

Trigger: config.medium.cookies[user] is defined, but getWebInlineRecommendedFeedQuery(user, cookie) resolves falsy. Medium's GraphQL endpoint silently signals auth failure.

Common situations: Expired session cookie; partial cookie copy missing the sid; Medium changed its auth flow; account logged out elsewhere.

Related errors


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