Mintplex-Labs/anything-llm · error

Internal Server Error

Error message

Internal Server Error

What it means

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).

Source

Thrown at server/endpoints/api/embed/index.js:74

    */
    try {
      const embeds = await EmbedConfig.whereWithWorkspace();
      const filteredEmbeds = embeds.map((embed) => ({
        id: embed.id,
        uuid: embed.uuid,
        enabled: embed.enabled,
        chat_mode: embed.chat_mode,
        createdAt: embed.createdAt,
        workspace: {
          id: embed.workspace.id,
          name: embed.workspace.name,
        },
        chat_count: embed._count.embed_chats,
      }));
      response.status(200).json({ embeds: filteredEmbeds });
    } catch (e) {
      console.error(e.message, e);
      response.sendStatus(500).end();
    }
  });

  app.get(
    "/v1/embed/:embedUuid/chats",
    [validApiKey],
    async (request, response) => {
      /*
      #swagger.tags = ['Embed']
      #swagger.description = 'Get all chats for a specific embed'
      #swagger.parameters['embedUuid'] = {
        in: 'path',
        description: 'UUID of the embed',
        required: true,
        type: 'string'
      }
      #swagger.responses[200] = {
        content: {

View on GitHub (pinned to 526360e320)

Solutions

  1. Inspect the server log for the Prisma/property-access error printed by console.error.
  2. Verify the database is reachable and Prisma migrations are up to date.
  3. If the failure is a null embed.workspace access, clean up embed configs whose workspace_id no longer resolves.
  4. Confirm the Prisma client version supports the _count.embed_chats relation used in the map.
  5. Restart the server after a DB restore/migration to re-establish the Prisma client.
Defensive patterns

Strategy: type-guard

Validate before calling

// No request body; ensure DB is healthy first.
const probe = await fetch('/v1/system/vector-count');
if (!probe.ok) throw new Error('backend unhealthy; embeds list likely to fail');

Type guard

function isEmbedListPayload(v) {
  return v != null && typeof v === 'object' && Array.isArray(v.embeds) && v.embeds.every(e =>
    e && typeof e.uuid === 'string' && e.workspace && typeof e.workspace.name === 'string'
  );
}

Try / catch

try {
  const r = await fetch('/v1/embeds');
  if (r.status === 500) throw new Error('embeds list failed - check Prisma/DB and orphaned embed configs');
  const json = await r.json();
  if (!isEmbedListPayload(json)) throw new Error('unexpected embeds payload');
} catch (e) { throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/417667850ad5a15d. Report an issue: GitHub.