DIYgod/RSSHub · error · ConfigNotFoundError
TELEGRAM_SESSION is not configured
Error message
TELEGRAM_SESSION is not configured
What it means
getClient initializes the MTProto TelegramClient from a StringSession. It throws ConfigNotFoundError when neither the passed-in session argument nor config.telegram.session is set, because a StringSession cannot be constructed from nothing and no prior client exists to reuse.
Source
Thrown at lib/routes/telegram/tglib/client.ts:11
import { Api, TelegramClient } from 'teleproto';
import type { UserAuthParams } from 'teleproto/client/auth';
import { StringSession } from 'teleproto/sessions/index.js';
import { config } from '@/config';
import ConfigNotFoundError from '@/errors/types/config-not-found';
let client: TelegramClient | undefined;
export async function getClient(authParams?: UserAuthParams, session?: string) {
if (!config.telegram.session && session === undefined) {
throw new ConfigNotFoundError('TELEGRAM_SESSION is not configured');
}
if (client) {
return client;
}
const apiId = Number(config.telegram.apiId ?? 4);
const apiHash = config.telegram.apiHash ?? '014b35b6184100b085b0d0572f9b5103';
const stringSession = new StringSession(session ?? config.telegram.session);
client = new TelegramClient(stringSession, apiId, apiHash, {
connectionRetries: Infinity,
autoReconnect: true,
retryDelay: 3000,
maxConcurrentDownloads: Number(config.telegram.maxConcurrentDownloads ?? 10),
proxy:
config.telegram.proxy?.host && config.telegram.proxy.port && config.telegram.proxy.secret
? {
ip: config.telegram.proxy.host,
port: Number(config.telegram.proxy.port),View on GitHub (pinned to bed535e087)
Solutions
- Generate a StringSession using the teleproto/telethon session generator and set TELEGRAM_SESSION in the RSSHub environment, then restart.
- Ensure TELEGRAM_API_ID and TELEGRAM_API_HASH are also set so the client can authenticate the session.
- If the session was invalidated (logged out, password change), regenerate it.
- Verify the env var is visible to the process (print config.telegram.session presence, not value) to rule out a missing export.
Example fix
// before
if (!config.telegram.session && session === undefined) {
throw new ConfigNotFoundError('TELEGRAM_SESSION is not configured');
}
// after: also require api credentials and name the env vars
if (!config.telegram.session && session === undefined) {
throw new ConfigNotFoundError('TELEGRAM_SESSION is not configured. Generate a StringSession and set TELEGRAM_SESSION (plus TELEGRAM_API_ID/TELEGRAM_API_HASH) in RSSHub config.');
} Defensive patterns
Strategy: validation
Validate before calling
import { config } from '@/config';
function mtprotoConfigured(): boolean {
return Boolean(config.telegram?.session);
}
// only register/enable MTProto routes when mtprotoConfigured() is true Type guard
function hasTelegramSession(): boolean {
return Boolean(config.telegram && (config.telegram as { session?: string }).session);
} Try / catch
try {
return await getClient();
} catch (e) {
if (e instanceof ConfigNotFoundError && /TELEGRAM_SESSION/.test(e.message)) {
// return a 503 with setup instructions instead of crashing
return unavailable('Set TELEGRAM_SESSION to enable Telegram media routes.');
}
throw e;
} Prevention
- Generate a StringSession once and store it in TELEGRAM_SESSION.
- Also set TELEGRAM_API_ID and TELEGRAM_API_HASH so the session authenticates.
- Gate MTProto-dependent routes on config presence so they are not exposed unconfigured.
- Regenerate the session if it is logged out or revoked.
When it happens
Trigger: Any Telegram MTProto route (channel-media, etc.) calls getClient() on an instance where TELEGRAM_SESSION was never configured and the caller did not supply a session string.
Common situations: Self-hosted RSSHub without TELEGRAM_SESSION; the session string expired/was revoked; the env var was set in a different shell/systemd unit than the one running RSSHub.
Related errors
- Telegram Sticker Pack RSS is disabled due to the lack of <a
- Cannot start TG: ${err}
- Authentication failed. Access denied.\n${requestPath}
- Login required
- Disqus RSS is disabled due to the lack of <a href="https://d
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/c69837a064e52850.
Report an issue: GitHub.