DIYgod/RSSHub · error · ConfigNotFoundError

MIXI2_AUTH_TOKEN and MIXI2_AUTH_KEY are required

Error message

MIXI2_AUTH_TOKEN and MIXI2_AUTH_KEY are required

What it means

Thrown as ConfigNotFoundError by getClient() in the mixi2 utils — the shared factory that builds a MixiClient for all mixi2 routes. It requires BOTH config.mixi2.authToken and config.mixi2.authKey; if either is falsy the route is disabled. These credentials authenticate against mixi's private API (the auth_token is a cookie-style token and auth_key a signing key used by the mixi2 SDK).

Source

Thrown at lib/routes/mixi2/utils.ts:13

import type { Persona, Post } from 'mixi2';
import { Category, MixiClient } from 'mixi2';

import { config } from '@/config';
import ConfigNotFoundError from '@/errors/types/config-not-found';
import ofetch from '@/utils/ofetch';
import { parseDate } from '@/utils/parse-date';

export function getClient() {
    const { authToken, authKey } = config.mixi2;

    if (!authToken || !authKey) {
        throw new ConfigNotFoundError('MIXI2_AUTH_TOKEN and MIXI2_AUTH_KEY are required');
    }

    return new MixiClient(`auth_token=${authToken}`, authKey, {
        httpAdapter: ofetch,
    });
}

export function parsePost(post: Post) {
    let description = post.text ? `<p>${post.text}</p>` : '';

    const medias = post.medias ?? [];
    for (const media of medias) {
        if (media.category === Category.CATEGORY_POST_IMAGE) {
            description += `<img src="${media.postImage?.largeImageUrl ?? media.postImage?.smallImageUrl}"${media.description ? `alt="${media.description}"` : ''} />`;
        } else if (media.category === Category.CATEGORY_POST_VIDEO) {
            description += `<img src="${media.postVideo?.previewImageUrl}" alt="${media.description}" />`;
        }
    }

View on GitHub (pinned to bed535e087)

Solutions

  1. Obtain the auth_token and auth_key for a mixi account (capture from a logged-in mixi.social session per the mixi2 SDK docs) and set both MIXI2_AUTH_TOKEN and MIXI2_AUTH_KEY in RSSHub's environment.
  2. Restart RSSHub and confirm both vars are present in the process env.
  3. If tokens expired, re-capture a fresh session and update both values.
  4. Note this route is effectively self-host only — the credentials are per-account.
Defensive patterns

Strategy: validation

Validate before calling

const { authToken, authKey } = config.mixi2;
if (!authToken || !authKey) {
    throw new ConfigNotFoundError('Set both MIXI2_AUTH_TOKEN and MIXI2_AUTH_KEY to enable mixi2 routes.');
}

Type guard

function hasMixi2Config(c: any): c is { mixi2: { authToken: string; authKey: string } } {
    return typeof c?.mixi2?.authToken === 'string' && typeof c?.mixi2?.authKey === 'string' && c.mixi2.authToken.length > 0 && c.mixi2.authKey.length > 0;
}

Prevention

When it happens

Trigger: Any mixi2 route is hit while MIXI2_AUTH_TOKEN or MIXI2_AUTH_KEY is unset. getClient() reads config.mixi2 and throws before constructing MixiClient. Because getClient is called inside each handler, the error appears on the first request to any mixi2 feed.

Common situations: Fresh deploy without the mixi2 secrets; only one of the two vars set; vars named with wrong case in the environment; tokens rotated by mixi and not refreshed.

Related errors


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