{"record":{"id":"417667850ad5a15d","repo":"Mintplex-Labs/anything-llm","slug":"internal-server-error-417667","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/api/embed/index.js","lineNumber":74,"sourceCode":"    */\n    try {\n      const embeds = await EmbedConfig.whereWithWorkspace();\n      const filteredEmbeds = embeds.map((embed) => ({\n        id: embed.id,\n        uuid: embed.uuid,\n        enabled: embed.enabled,\n        chat_mode: embed.chat_mode,\n        createdAt: embed.createdAt,\n        workspace: {\n          id: embed.workspace.id,\n          name: embed.workspace.name,\n        },\n        chat_count: embed._count.embed_chats,\n      }));\n      response.status(200).json({ embeds: filteredEmbeds });\n    } catch (e) {\n      console.error(e.message, e);\n      response.sendStatus(500).end();\n    }\n  });\n\n  app.get(\n    \"/v1/embed/:embedUuid/chats\",\n    [validApiKey],\n    async (request, response) => {\n      /*\n      #swagger.tags = ['Embed']\n      #swagger.description = 'Get all chats for a specific embed'\n      #swagger.parameters['embedUuid'] = {\n        in: 'path',\n        description: 'UUID of the embed',\n        required: true,\n        type: 'string'\n      }\n      #swagger.responses[200] = {\n        content: {","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/endpoints/api/embed/index.js#L56-L92","documentation":"HTTP 500 returned by GET /v1/embeds in AnythingLLM. The handler loads embed configurations (with relations workspace and _count.embed_chats), filters/maps them into a trimmed DTO, and returns {embeds}. Any exception - Prisma query failure, relation load error, mapping error on a missing relation - becomes sendStatus(500).","triggerScenarios":"Database connection lost or misconfigured so the Prisma findMany throws; embed.workspace being null when the map accesses embed.workspace.id/workspace.name (orphaned embed after workspace deletion); embed._count undefined on a Prisma version that does not return counts; corrupt embed_config row.","commonSituations":"Workspace deleted but its embed config rows left behind, making embed.workspace null; Prisma schema/version mismatch dropping _count; database unreachable; migrating databases without running the Prisma migration.","solutions":["Inspect the server log for the Prisma/property-access error printed by console.error.","Verify the database is reachable and Prisma migrations are up to date.","If the failure is a null embed.workspace access, clean up embed configs whose workspace_id no longer resolves.","Confirm the Prisma client version supports the _count.embed_chats relation used in the map.","Restart the server after a DB restore/migration to re-establish the Prisma client."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// No request body; ensure DB is healthy first.\nconst probe = await fetch('/v1/system/vector-count');\nif (!probe.ok) throw new Error('backend unhealthy; embeds list likely to fail');","typeGuard":"function isEmbedListPayload(v) {\n  return v != null && typeof v === 'object' && Array.isArray(v.embeds) && v.embeds.every(e =>\n    e && typeof e.uuid === 'string' && e.workspace && typeof e.workspace.name === 'string'\n  );\n}","tryCatchPattern":"try {\n  const r = await fetch('/v1/embeds');\n  if (r.status === 500) throw new Error('embeds list failed - check Prisma/DB and orphaned embed configs');\n  const json = await r.json();\n  if (!isEmbedListPayload(json)) throw new Error('unexpected embeds payload');\n} catch (e) { throw e; }","preventionTips":["Keep Prisma migrations current so embed.workspace is never null.","Clean up embed configs whose workspace was deleted to avoid null-relation map errors.","Ensure the Prisma client version supports the _count.embed_chats relation.","Monitor DB connectivity; this endpoint fails first when the DB is down."],"tags":["anythingllm","embed","prisma","database","express","http-500"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}