DIYgod/RSSHub · error · ConfigNotFoundError

This user is an R18 creator, PIXIV_REFRESHTOKEN is required.

Error message

This user is an R18 creator, PIXIV_REFRESHTOKEN is required.
pixiv RSS is disabled due to the lack of relevant config.
該用戶爲 R18 創作者,需要 PIXIV_REFRESHTOKEN。

What it means

Thrown by getNSFWSeriesNovels (pixiv R18 novel series path) when config.pixiv or config.pixiv.refreshToken is falsy. Pixiv gates R18/NSFW novel series behind an authenticated account, so RSSHub refuses the request before any network call rather than returning partial or login-walled data. It is a ConfigNotFoundError, signalling a deployment-configuration problem, not a bad user request.

Source

Thrown at lib/routes/pixiv/novel-api/series/nsfw.ts:35

        headers: {
            ...maskHeader,
            Authorization: 'Bearer ' + token,
        },
        searchParams: queryString.stringify({
            series_id: seriesId,
            last_order: offset,
        }),
    });
    return rsp.data as AppNovelSeries;
}

export async function getNSFWSeriesNovels(seriesId: string, limit: number = 10): Promise<SeriesFeed> {
    if (limit > 30) {
        limit = 30;
    }

    if (!config.pixiv || !config.pixiv.refreshToken) {
        throw new ConfigNotFoundError('This user is an R18 creator, PIXIV_REFRESHTOKEN is required.\npixiv RSS is disabled due to the lack of relevant config.\n該用戶爲 R18 創作者,需要 PIXIV_REFRESHTOKEN。');
    }

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

    const seriesResponse = await got(`${baseUrl}/ajax/novel/series/${seriesId}`, {
        headers: {
            ...maskHeader,
            Authorization: 'Bearer ' + token,
        },
    });
    const seriesData = seriesResponse.data as SeriesDetail;

    let offset = seriesData.body.total - limit;
    if (offset < 0) {
        offset = 0;

View on GitHub (pinned to bed535e087)

Solutions

  1. Set PIXIV_REFRESHTOKEN in your RSSHub environment (obtain it via the pixiv login refresh-token flow documented at https://docs.rsshub.app/deploy/config#pixiv), then restart the instance.
  2. Confirm the variable is actually loaded: print config.pixiv in a debug route or check startup logs.
  3. If you only need safe-for-work series content, call the SFW series route instead so auth is not required.
  4. For Docker/Compose, ensure the env var is passed through to the container and not shadowed by an empty value.

Example fix

// before: .env has no pixiv entry
// after (in .env):
PIXIV_REFRESHTOKEN=your_refresh_token_here
Defensive patterns

Strategy: validation

Validate before calling

import { config } from '@/config';
function canFetchNSFWSeries(): boolean {
  return Boolean(config.pixiv && config.pixiv.refreshToken);
}
// before calling getNSFWSeriesNovels:
if (!canFetchNSFWSeries()) {
  // surface a friendly 'PIXIV_REFRESHTOKEN not configured' notice instead of throwing
}

Type guard

const hasPixivAuth = (c: typeof config): c is typeof config & { pixiv: { refreshToken: string } } =>
  Boolean(c.pixiv && typeof c.pixiv.refreshToken === 'string' && c.pixiv.refreshToken.length > 0);

Try / catch

try {
  const feed = await getNSFWSeriesNovels(seriesId, limit);
} catch (e) {
  if (e instanceof ConfigNotFoundError) {
    // config problem: instruct operator, do not retry
  }
  throw e;
}

Prevention

When it happens

Trigger: Requesting the NSFW novel series route for an R18 series while PIXIV_REFRESHTOKEN is unset, empty string, or config.pixiv is entirely undefined (env var never loaded). Reached only via the NSFW branch, i.e. when the caller knows the series is R18.

Common situations: Fresh RSSHub deploy without pixiv env vars set; .env file missing or not loaded by the process; Docker container started without -e PIXIV_REFRESHTOKEN; var name misspelled; config module read before env population.

Related errors


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