Mintplex-Labs/anything-llm · error

Internal Server Error

Error message

Internal Server Error

What it means

GET /v1/admin/users (server/endpoints/api/admin/index.js:41) returns HTTP 500 from the catch at line 79-81 when User.where() throws after the multi-user-mode guard at line 72 has passed. The handler has no other awaited logic, so the throw is a database-side failure of the users listing query.

Source

Thrown at server/endpoints/api/admin/index.js:81

      schema: {
        "$ref": "#/definitions/InvalidAPIKey"
      }
    }
     #swagger.responses[401] = {
      description: "Instance is not in Multi-User mode. Method denied",
    }
    */
    try {
      if (!multiUserMode(response)) {
        response.sendStatus(401).end();
        return;
      }

      const users = await User.where();
      response.status(200).json({ users });
    } catch (e) {
      console.error(e);
      response.sendStatus(500).end();
    }
  });

  app.post("/v1/admin/users/new", [validApiKey], async (request, response) => {
    /*
    #swagger.tags = ['Admin']
    #swagger.description = 'Create a new user with username and password. Methods are disabled until multi user mode is enabled via the UI.'
    #swagger.requestBody = {
        description: 'Key pair object that will define the new user to add to the system.',
        required: true,
        content: {
          "application/json": {
            example: {
              username: "sample-sam",
              password: 'hunter2',
              role: 'default | admin'
            }
          }

View on GitHub (pinned to 526360e320)

Solutions

  1. Read server logs for the SQL error printed by console.error(e).
  2. Run pending migrations and regenerate the ORM client (npx prisma generate / migrate deploy).
  3. Confirm the users table exists and the API key used has not been revoked between auth and the query.
  4. If the user count is very large, paginate the listing rather than returning all rows at once.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const users = await User.where();
  response.status(200).json({ users });
} catch (e) {
  console.error('GET /v1/admin/users failed:', e);
  response.status(503).json({ users:[], error:'User listing unavailable' });
}

Prevention

When it happens

Trigger: User.where() running against a users table missing or schema-drifted; the users table enormous enough to hit a query timeout; prisma/sequelize client generated against a schema older than the running DB; transient DB connection drop after the middleware ran but before the query.

Common situations: Post-migration prisma client not regenerated; a partial migration that did not create the users table; concurrent heavy writes locking the table.

Understand the failure class

Related errors


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