{"record":{"id":"e9862a0fec36c5ab","repo":"Mintplex-Labs/anything-llm","slug":"internal-server-error-e9862a","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/telegram.js","lineNumber":67,"sourceCode":"          });\n          if (availableThreads.length) thread = availableThreads[0];\n        }\n\n        return response.status(200).json({\n          config: {\n            active: connector.active,\n            connected: service.isRunning,\n            bot_username: connector.config.bot_username || null,\n            default_workspace: workspace?.name || workspaceSlug || \"—\",\n            active_thread_name: thread?.name || \"Default\",\n            chat_model: workspace?.chatModel || \"System default\",\n            voice_response_mode:\n              connector.config.voice_response_mode || \"text_only\",\n          },\n        });\n      } catch (e) {\n        console.error(e.message, e);\n        response.sendStatus(500);\n      }\n    }\n  );\n\n  /**\n   * Verify token, save config, and start the Telegram bot.\n   */\n  app.post(\n    \"/telegram/connect\",\n    [validatedRequest, isSingleUserMode],\n    async (request, response) => {\n      try {\n        const { bot_token, default_workspace = null } = reqBody(request);\n        if (!bot_token) {\n          return response.status(400).json({\n            success: false,\n            error: \"Bot token is required.\",\n          });","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/endpoints/telegram.js#L49-L85","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check Telegram connector health before reading config\nasync function isTelegramConnectorHealthy() {\n  try {\n    const res = await fetch('/telegram/status');\n    return res.ok;\n  } catch {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const res = await fetch('/telegram/config');\n  if (res.status === 500) {\n    // Connector record may be corrupted — reconnect\n    console.error('Telegram config read failed; connector may be corrupted');\n  }\n  const { config } = await res.json();\n} catch (e) {\n  console.error('Failed to read Telegram config:', e.message);\n}","preventionTips":["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."],"tags":["telegram","config","database","connector","internal-error"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}