Mintplex-Labs/anything-llm · warning

Internal Server Error

Error message

Internal Server Error

What it means

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.

Source

Thrown at server/endpoints/embedManagement.js:29

const {
  chatHistoryViewable,
} = require("../utils/middleware/chatHistoryViewable");

function embedManagementEndpoints(app) {
  if (!app) return;

  app.get(
    "/embeds",
    [validatedRequest, flexUserRoleValid([ROLES.admin])],
    async (_, response) => {
      try {
        const embeds = await EmbedConfig.whereWithWorkspace({}, null, {
          createdAt: "desc",
        });
        response.status(200).json({ embeds });
      } catch (e) {
        console.error(e);
        response.sendStatus(500).end();
      }
    }
  );

  app.post(
    "/embeds/new",
    [validatedRequest, flexUserRoleValid([ROLES.admin])],
    async (request, response) => {
      try {
        const user = await userFromSession(request, response);
        const data = reqBody(request);
        const { embed, message: error } = await EmbedConfig.new(data, user?.id);
        await EventLogs.logEvent(
          "embed_created",
          { embedId: embed.id },
          user?.id
        );
        response.status(200).json({ embed, error });

View on GitHub (pinned to 526360e320)

Solutions

  1. Verify migrations are applied (npx prisma migrate deploy) and the embed_configs table exists.
  2. Confirm DB connectivity and that the server has fully started.
  3. Check the server log for the underlying Prisma error printed by console.error(e).
  4. Restart the server to re-establish the Prisma client connection.
Defensive patterns

Strategy: try-catch

Try / catch

// Admin list — degrade to empty list on 500 and surface a health warning.
async function listEmbeds(baseUrl, token) {
  try {
    const res = await fetch(`${baseUrl}/embeds`, { headers: { Authorization: `Bearer ${token}` } });
    if (res.ok) return await res.json();
  } catch (e) { /* network */ }
  return { embeds: [], degraded: true };
}

Prevention

When it happens

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

Common situations: Fresh deployment where migrations have not run (embed_configs table/view missing); server restarting under load; Postgres credentials rotated but the app not restarted.

Understand the failure class

Related errors


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