Mintplex-Labs/anything-llm · error

Internal Server Error

Error message

Internal Server Error

What it means

The catch-all 500 for POST /v1/workspace/:slug/thread/new. The workspace check (400) already passed, and WorkspaceThread.new catches its own Prisma errors internally (returning {thread:null, message}), so this 500 fires only when something outside those guarded calls rejects — most commonly a database engine fault (SQLITE_BUSY/locked sqlite file, Prisma engine crash, unreadable storage dir) or a response serialization failure. The handler logs e.message to the server console.

Solutions

  1. Check the server console line printed by console.error(e.message, e) — it names the underlying Prisma/SQLite error
  2. Ensure only one server process uses the storage directory at a time and nothing else holds the sqlite file
  3. Verify disk space and storage/ directory permissions for the server process user
  4. Restart the container after upgrades so pending Prisma migrations/schema sync run
Defensive patterns

Strategy: try-catch

Type guard

/** 500 from this endpoint is a server fault, not a client error. */
function isServerFault(res) {
  return res.status === 500;
}

Try / catch

try {
  const { thread, message } = await createThread(slug, body);
} catch (e) {
  if (e?.response?.status === 500)
    throw new Error("thread creation failed server-side — check server logs (likely DB locked/corrupt)");
  throw e;
}

Prevention

When it happens

Trigger: SQLite database file locked by a concurrent process (backup job, two server instances on one storage dir), disk full so Prisma cannot write, storage/ permissions broken after a container migration, or prisma client out of sync with the schema (schema drift after upgrading without restarting).

Common situations: Running dev server and a worker against the same storage dir; docker volume permission changes (chown'ed storage); upgrading the app image but keeping an old database file that needs migration; extremely rapid parallel thread creations hitting sqlite write locks.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@f92433b4ea (2026-08-18). Data as JSON: /api/errors/56774cb6902fb902. Report an issue: GitHub.

Appendix: source

Thrown at server/endpoints/api/workspaceThread/index.js:106

          workspace,
          userId ? Number(userId) : null,
          { name, slug }
        );

        await Telemetry.sendTelemetry("workspace_thread_created", {
          multiUserMode: multiUserMode(response),
          LLMSelection: process.env.LLM_PROVIDER || "openai",
          Embedder: process.env.EMBEDDING_ENGINE || "inherit",
          VectorDbSelection: process.env.VECTOR_DB || "lancedb",
          TTSSelection: process.env.TTS_PROVIDER || "native",
        });
        await EventLogs.logEvent("api_workspace_thread_created", {
          workspaceName: workspace?.name || "Unknown Workspace",
        });
        response.status(200).json({ thread, message });
      } catch (e) {
        console.error(e.message, e);
        response.sendStatus(500).end();
      }
    }
  );

  app.post(
    "/v1/workspace/:slug/thread/:threadSlug/update",
    [validApiKey],
    async (request, response) => {
      /*
      #swagger.tags = ['Workspace Threads']
      #swagger.description = 'Update thread name by its unique slug.'
      #swagger.parameters['slug'] = {
          in: 'path',
          description: 'Unique slug of workspace',
          required: true,
          type: 'string'
      }
      #swagger.parameters['threadSlug'] = {

View on GitHub (pinned to f92433b4ea)