{"record":{"id":"0fbb9daff2310e0a","repo":"Mintplex-Labs/anything-llm","slug":"internal-server-error-0fbb9d","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"warning","filePath":"server/endpoints/embedManagement.js","lineNumber":29,"sourceCode":"const {\n  chatHistoryViewable,\n} = require(\"../utils/middleware/chatHistoryViewable\");\n\nfunction embedManagementEndpoints(app) {\n  if (!app) return;\n\n  app.get(\n    \"/embeds\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (_, response) => {\n      try {\n        const embeds = await EmbedConfig.whereWithWorkspace({}, null, {\n          createdAt: \"desc\",\n        });\n        response.status(200).json({ embeds });\n      } catch (e) {\n        console.error(e);\n        response.sendStatus(500).end();\n      }\n    }\n  );\n\n  app.post(\n    \"/embeds/new\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (request, response) => {\n      try {\n        const user = await userFromSession(request, response);\n        const data = reqBody(request);\n        const { embed, message: error } = await EmbedConfig.new(data, user?.id);\n        await EventLogs.logEvent(\n          \"embed_created\",\n          { embedId: embed.id },\n          user?.id\n        );\n        response.status(200).json({ embed, error });","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/endpoints/embedManagement.js#L11-L47","documentation":"HTTP 500 from the catch-all of GET /embeds (admin list of embed configs). EmbedConfig.whereWithWorkspace wraps its Prisma findMany in try/catch and returns [] on error, so under normal conditions this handler returns 200 with {embeds:[]} even when the DB query fails. The 500 fires only when an exception escapes that boundary — essentially a Prisma-client-not-initialized or a hard serialization fault, making this a defensive safety net.","triggerScenarios":"Hitting GET /embeds during the boot window before Prisma is connected, or when the DB schema is so far out of sync that Prisma throws at query-construction time before the model's catch engages.","commonSituations":"Fresh deployment where migrations have not run (embed_configs table/view missing); server restarting under load; Postgres credentials rotated but the app not restarted.","solutions":["Verify migrations are applied (npx prisma migrate deploy) and the embed_configs table exists.","Confirm DB connectivity and that the server has fully started.","Check the server log for the underlying Prisma error printed by console.error(e).","Restart the server to re-establish the Prisma client connection."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Admin list — degrade to empty list on 500 and surface a health warning.\nasync function listEmbeds(baseUrl, token) {\n  try {\n    const res = await fetch(`${baseUrl}/embeds`, { headers: { Authorization: `Bearer ${token}` } });\n    if (res.ok) return await res.json();\n  } catch (e) { /* network */ }\n  return { embeds: [], degraded: true };\n}","preventionTips":["Run Prisma migrations after upgrade so the embed_configs table exists.","Confirm the server finished booting (DB connected) before loading the admin embeds page.","Treat a recurring 500 here as a global DB-health problem."],"tags":["embed-management","express","prisma","admin","api"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}