Mintplex-Labs/anything-llm · error
Internal Server Error
Error message
Internal Server Error
What it means
Returned by GET /telegram/config when any of the handler's database queries or service instantiation throws. The catch block at lines 65-67 logs `e.message` and sends a bare 500. This endpoint is single-user-only (isSingleUserMode middleware) and resolves the connector config, workspace, thread, and chat model to build a status response. The handler accesses nested properties like `connector.config.bot_username`, `connector.config.approved_users` which can throw if the connector config structure is malformed or null.
Source
Thrown at server/endpoints/telegram.js:67
});
if (availableThreads.length) thread = availableThreads[0];
}
return response.status(200).json({
config: {
active: connector.active,
connected: service.isRunning,
bot_username: connector.config.bot_username || null,
default_workspace: workspace?.name || workspaceSlug || "—",
active_thread_name: thread?.name || "Default",
chat_model: workspace?.chatModel || "System default",
voice_response_mode:
connector.config.voice_response_mode || "text_only",
},
});
} catch (e) {
console.error(e.message, e);
response.sendStatus(500);
}
}
);
/**
* Verify token, save config, and start the Telegram bot.
*/
app.post(
"/telegram/connect",
[validatedRequest, isSingleUserMode],
async (request, response) => {
try {
const { bot_token, default_workspace = null } = reqBody(request);
if (!bot_token) {
return response.status(400).json({
success: false,
error: "Bot token is required.",
});View on GitHub (pinned to 526360e320)
Solutions
- Check server console for the logged error message to identify which query or property access failed.
- Verify the telegram connector's config JSON in the database is valid and non-null.
- If the referenced workspace no longer exists, reconnect the Telegram bot to a valid workspace via POST /telegram/connect.
- Ensure the database is accessible and not locked.
Defensive patterns
Strategy: try-catch
Validate before calling
// Check Telegram connector health before reading config
async function isTelegramConnectorHealthy() {
try {
const res = await fetch('/telegram/status');
return res.ok;
} catch {
return false;
}
} Try / catch
try {
const res = await fetch('/telegram/config');
if (res.status === 500) {
// Connector record may be corrupted — reconnect
console.error('Telegram config read failed; connector may be corrupted');
}
const { config } = await res.json();
} catch (e) {
console.error('Failed to read Telegram config:', e.message);
} Prevention
- Ensure the telegram connector's config JSON in the database is valid and non-null.
- If the referenced workspace was deleted, reconnect the bot to a valid workspace.
- Monitor database health to prevent corrupted connector records.
When it happens
Trigger: `ExternalCommunicationConnector.get('telegram')` returns a connector with a null or malformed `config` property, causing `connector.config.approved_users` to throw. `Workspace.get({ slug: workspaceSlug })` or `WorkspaceThread.where()` fails due to a database issue. The `TelegramBotService` constructor throws if an internal dependency fails to initialize.
Common situations: The telegram connector row in the database has a corrupted or null config JSON field (e.g., after a partial migration). A workspace referenced in the connector config was deleted, leaving a dangling slug. Database connection pool exhausted or file locked.
Understand the failure class
- HTTP status errors: handling 4xx and 5xx responses — how to handle 4xx and 5xx responses properly.
Related errors
- Internal Server Error
- No base URL was set.
- No OpenAI API key was set.
- Invalid runtime setting: ${key}
- QEMU directory not found: ${dir} Contents of ${parent}: ${co
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/e9862a0fec36c5ab.
Report an issue: GitHub.