{"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":"error","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/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/embedManagement.js#L11-L47","documentation":"Catch-all 500 for GET /embeds, the admin listing of embed configurations. EmbedConfig.whereWithWorkspace runs a Prisma join (embed_configs with workspaces); if that query rejects — schema drift after an upgrade, missing columns, unreadable/locked sqlite file — the handler logs the error and returns a bare 500. Auth/role failures never reach this line (they are handled by flexUserRoleValid middleware earlier).","triggerScenarios":"Opening the Embeddable Chat Widgets admin page after upgrading the app but before the DB schema was migrated; sqlite file locked or corrupted; storage volume mounted read-only; Prisma client binary missing for the platform.","commonSituations":"Pulling a new container image while keeping an old storage volume; moving the storage dir between hosts with different permissions; a crashed migration leaving half-applied schema changes.","solutions":["Check server console for the Prisma error printed by console.error(e)","Restart the server/container so boot-time migrations and Prisma schema sync complete, then reload /embeds","Confirm the storage directory and anythingllm.db are writable and owned by the server user","If schema drift persists, restore the DB from a backup taken on the same app version"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"/** Any non-200 on /embeds (auth already handled by middleware) is a listing fault. */\nfunction isEmbedsListFault(res) {\n  return res.status === 500;\n}","tryCatchPattern":"try {\n  const { embeds } = await listEmbeds();\n} catch (e) {\n  if (e?.response?.status === 500)\n    throw new Error(\"embed listing failed — likely DB migration/schema issue; restart server and check logs\");\n  throw e;\n}","preventionTips":["Restart the server after every version upgrade before using admin pages","Back up storage/anythingllm.db before upgrading so schema drift is recoverable","Keep /embeds out of automated health checks; gate on logs instead"],"tags":["http-500","embed-management","prisma","admin-ui"],"backgroundTag":"database-query-failed","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}