DIYgod/RSSHub · error · ConfigNotFoundError

Twitter API is not configured

Error message

Twitter API is not configured

What it means

ConfigNotFoundError from the Twitter developer-API client pool: after `init()` runs, if no valid consumer key/secret pair was pushed into `appClients`, getAppClient cannot return a client and throws. This is the runtime signal that the Twitter API v2 credentials are missing or all invalid.

Source

Thrown at lib/routes/twitter/api/developer-api/api.ts:66

                }).readOnly,
                isUserAuth: true,
            });
        } else {
            appClients.push({
                client: new TwitterApi({
                    appKey: consumerKey,
                    appSecret: consumerSecret,
                }).readOnly,
                isUserAuth: false,
            });
        }
    }
};

export const getAppClient = async () => {
    init();
    if (!appClients.length) {
        throw new ConfigNotFoundError('Twitter API is not configured');
    }
    index += 1;

    const currentWrapper = appClients[index % appClients.length];

    return currentWrapper.isUserAuth ? currentWrapper.client : await currentWrapper.client.appLogin();
};

const mapUserToLegacy = (user: Record<string, any>) =>
    user
        ? {
              id_str: user.id,
              name: user.name,
              screen_name: user.username,
              description: user.description,
              profile_image_url: user.profile_image_url,
              profile_image_url_https: user.profile_image_url,
              url: user.url,

View on GitHub (pinned to bed535e087)

Solutions

  1. Apply for a Twitter developer project and create an app with v2 read access.
  2. Set `TWITTER_CONSUMER_KEY` and `TWITTER_CONSUMER_SECRET` (comma-separated for multiple clients) in RSSHub config and restart.
  3. Ensure secrets are non-empty for each key index; mismatches cause silent skips.
Defensive patterns

Strategy: validation

Validate before calling

init();
if (!appClients.length) { throw new ConfigNotFoundError('Set TWITTER_CONSUMER_KEY/TWITTER_CONSUMER_SECRET with at least one valid pair'); }

Type guard

const hasClientPool = (a: unknown): a is { length: number } => Array.isArray(a) && a.length > 0;

Prevention

When it happens

Trigger: `config.twitter.consumerKey` or `config.twitter.consumerSecret` is unset, or every comma-separated pair has an empty secret (lines 37-39 `continue`), leaving appClients empty; getAppClient then throws on line 65-66.

Common situations: Self-hosted RSSHub without `TWITTER_CONSUMER_KEY`/`TWITTER_CONSUMER_SECRET`; keys revoked by X; only an auth token (web API) was configured but a route forced the developer API.

Related errors


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