Mintplex-Labs/anything-llm · error

Internal Server Error

Error message

Internal Server Error

What it means

Returned by GET /utils/metrics when building the system metrics object throws. The handler aggregates: `getGitVersion()` (spawns a child process — already has its own try-catch fallback returning '--'), `SystemSettings.isMultiUserMode()` (database query), `getDiskStorage()` (uses check-disk-space npm package — already has its own try-catch returning nulls), and `getDeploymentVersion()`. The outer catch at lines 29-31 sends a bare 500. Since getGitVersion and getDiskStorage have internal fallbacks, the most likely remaining throw source is `SystemSettings.isMultiUserMode()` or `getDeploymentVersion()`.

Source

Thrown at server/endpoints/utils.js:31

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

  app.get("/utils/metrics", async (_, response) => {
    try {
      const metrics = {
        online: true,
        version: getGitVersion(),
        mode: (await SystemSettings.isMultiUserMode())
          ? "multi-user"
          : "single-user",
        vectorDB: process.env.VECTOR_DB || "lancedb",
        storage: await getDiskStorage(),
        appVersion: getDeploymentVersion(),
      };
      response.status(200).json(metrics);
    } catch (e) {
      console.error(e);
      response.sendStatus(500).end();
    }
  });

  app.post(
    "/export-chat/:type",
    [validatedRequest, flexUserRoleValid([ROLES.all])],
    async (request, response) => {
      try {
        const { type } = request.params;
        if (!validExportTypes.includes(type))
          return response.sendStatus(400).end();

        const { workspaceSlug, threadSlug } = reqBody(request);
        const { Workspace } = require("../models/workspace");
        const { WorkspaceThread } = require("../models/workspaceThread");
        const { WorkspaceChats } = require("../models/workspaceChats");

        const user = await userFromSession(request, response);

View on GitHub (pinned to 526360e320)

Solutions

  1. Check server console for the specific error — it will reveal whether the failure is in the DB query, version lookup, or disk space check.
  2. Verify the database is initialized and the system_settings table exists.
  3. Check Docker volume mounts — the storage directory must be accessible.
  4. Ensure package.json exists in the deployment root for getDeploymentVersion().
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const res = await fetch('/utils/metrics');
  if (res.status === 500) {
    // Database or system-level failure — this endpoint is a health check
    // so failure here indicates a fundamental system issue
    console.error('System metrics unavailable — database or storage issue');
    return { online: false };
  }
  const metrics = await res.json();
} catch (e) {
  console.error('Metrics endpoint failed:', e.message);
}

Prevention

When it happens

Trigger: `SystemSettings.isMultiUserMode()` throws because the system_settings table is missing or the database is inaccessible. `getDeploymentVersion()` throws if it reads a package.json or version file that is missing or malformed. On Docker deployments, `getGitVersion()` returns '--' safely, but the disk space check or system settings query can fail if the storage mount is broken.

Common situations: Database not initialized (fresh container with missing migration step). Storage volume not mounted correctly in Docker. A corrupted or missing package.json or version file that getDeploymentVersion reads. Running in an environment where the check-disk-space package's native dependency fails.

Understand the failure class

Related errors


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