DIYgod/RSSHub · error · ConfigNotFoundError

Twitter API is not configured

Error message

Twitter API is not configured

What it means

ConfigNotFoundError from the Twitter API entrypoint's fallback stub: when neither the developer API, web API, nor third-party API is enabled, the `api` object stays as the placeholder whose `init()` throws. It is the top-level signal that no Twitter backend is configured.

Source

Thrown at lib/routes/twitter/api/index.ts:28

const enableWebApi = config.twitter.authToken;
const enableDeveloperApi = config.twitter.consumerKey && config.twitter.consumerSecret;

type ApiItem = (id: string, params?: Record<string, any>) => Promise<Record<string, any>> | Record<string, any> | null;
let api: {
    init: () => void;
    getUser: ApiItem;
    getUserTweets: ApiItem;
    getUserTweetsAndReplies: ApiItem;
    getUserMedia: ApiItem;
    getUserLikes: ApiItem;
    getUserTweet: ApiItem;
    getSearch: ApiItem;
    getList: ApiItem;
    getHomeTimeline: ApiItem;
    getHomeLatestTimeline: ApiItem;
} = {
    init: () => {
        throw new ConfigNotFoundError('Twitter API is not configured');
    },
    getUser: () => null,
    getUserTweets: () => null,
    getUserTweetsAndReplies: () => null,
    getUserMedia: () => null,
    getUserLikes: () => null,
    getUserTweet: () => null,
    getSearch: () => null,
    getList: () => null,
    getHomeTimeline: () => null,
    getHomeLatestTimeline: () => null,
};

if (enableThirdPartyApi || enableWebApi) {
    api = webApi;
} else if (enableDeveloperApi) {
    api = devApi;
}

View on GitHub (pinned to bed535e087)

Solutions

  1. Configure at least one Twitter backend: developer API (consumer key/secret), web API (auth token), or third-party API base URL.
  2. Restart RSSHub after setting the env vars so index.ts re-evaluates the enable flags.
  3. If using a docker compose setup, confirm the env vars are passed into the container.
Defensive patterns

Strategy: validation

Validate before calling

const enabled = config.twitter.consumerKey && config.twitter.consumerSecret || config.twitter.authToken || config.twitter.thirdPartyApi;
if (!enabled) throw new ConfigNotFoundError('No Twitter backend configured — set developer keys, an auth token, or a third-party API');

Type guard

const hasTwitterBackend = (c: { consumerKey?: string; consumerSecret?: string; authToken?: string; thirdPartyApi?: string }): boolean => Boolean((c.consumerKey && c.consumerSecret) || c.authToken || c.thirdPartyApi);

Prevention

When it happens

Trigger: None of `config.twitter.consumerKey`+`consumerSecret`, `config.twitter.authToken`, or `config.twitter.thirdPartyApi` is set, so the conditional upgrades in api/index.ts never replace the stub; calling `init()` (or any getter that triggers init) throws on line 27-28.

Common situations: Fresh RSSHub install with no Twitter env vars; all previously-set tokens were removed; the env var names changed between versions.

Related errors


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