DIYgod/RSSHub · error · ConfigNotFoundError

pixiv not login

Error message

pixiv not login

What it means

ConfigNotFoundError thrown by the ranking handler when getToken() returns falsy after the config guard passed. The OAuth refresh against oauth.secure.pixiv.net did not yield an access_token, leaving the module token null. Indicates configured-but-broken credentials.

Source

Thrown at lib/routes/pixiv/ranking.ts:156

        supportScihub: false,
        nsfw: true,
    },
    name: 'Rankings',
    maintainers: ['EYHN'],
    handler,
};

async function handler(ctx) {
    if (!config.pixiv || !config.pixiv.refreshToken) {
        throw new ConfigNotFoundError('pixiv RSS is disabled due to the lack of <a href="https://docs.rsshub.app/deploy/config#route-specific-configurations">relevant config</a>');
    }

    const mode = alias[ctx.req.param('mode')] ?? ctx.req.param('mode');
    const date = ctx.req.param('date') ? new Date(ctx.req.param('date')) : new Date();

    const token = await getToken();
    if (!token) {
        throw new ConfigNotFoundError('pixiv not login');
    }

    const response = await getRanking(mode, ctx.req.param('date') && date, token);

    const illusts = response.data.illusts;

    const dateStr = `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日 `;

    return {
        title: (ctx.req.param('date') ? dateStr : '') + titles[mode],
        link: links[mode],
        description: dateStr + titles[mode],
        item: illusts.map((illust, index) => {
            const images = pixivUtils.getImgs(illust);
            return {
                title: `#${index + 1} ${illust.title}`,
                pubDate: parseDate(illust.create_date),
                description: `${illust.caption}<br><p>画师:${illust.user.name} - 阅览数:${illust.total_view} - 收藏数:${illust.total_bookmarks}</p><br>${images.join('')}`,

View on GitHub (pinned to bed535e087)

Solutions

  1. Regenerate and set a fresh PIXIV_REFRESHTOKEN.
  2. Ensure network reachability to oauth.secure.pixiv.net (proxy if needed).
  3. Invalidate the 'pixiv:accessToken' cache entry.
  4. Inspect the OAuth response in logs to see pixiv's rejection reason.
Defensive patterns

Strategy: validation

Validate before calling

import { getToken } from './token';
const token = await getToken();
if (!token) {
  // abort ranking fetch; prompt token regeneration
}

Type guard

const isUsableToken = (t: unknown): t is string => typeof t === 'string' && t.length > 0;

Try / catch

try {
  const token = await getToken();
  if (!token) throw new ConfigNotFoundError('pixiv not login');
} catch (e) {
  if (e instanceof ConfigNotFoundError) {
    // refresh failed: clear cache, advise regenerating token
  }
}

Prevention

When it happens

Trigger: PIXIV_REFRESHTOKEN present but expired/revoked/invalid; oauth endpoint unreachable or region-blocked; empty token result cached for up to an hour under 'pixiv:accessToken'.

Common situations: Long-running token finally expired; server relocated behind a pixiv-blocked network; cache poisoned with a failed refresh result.

Related errors


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