Mintplex-Labs/anything-llm · error
Internal Server Error
Error message
Internal Server Error
What it means
Generic 500 from the GET /admin/users handler. The route is guarded by validatedRequest and strictMultiUserRoleValid([admin, manager]); inside the try it calls User.where() and returns JSON. Any unhandled exception in the query (DB unreachable, Prisma error, model throw) lands in the catch, which console.errors the stack and sends 500. The message 'Internal Server Error' is Express's default for sendStatus(500).
Source
Thrown at server/endpoints/admin.js:47
simpleSSOLoginDisabledMiddleware,
} = require("../utils/middleware/simpleSSOEnabled");
const {
workspaceDeletionProtection,
} = require("../utils/middleware/workspaceDeletionProtection");
function adminEndpoints(app) {
if (!app) return;
app.get(
"/admin/users",
[validatedRequest, strictMultiUserRoleValid([ROLES.admin, ROLES.manager])],
async (_request, response) => {
try {
const users = await User.where();
response.status(200).json({ users });
} catch (e) {
console.error(e);
response.sendStatus(500).end();
}
}
);
app.post(
"/admin/users/new",
[validatedRequest, strictMultiUserRoleValid([ROLES.admin, ROLES.manager])],
async (request, response) => {
try {
const currUser = await userFromSession(request, response);
const newUserParams = reqBody(request);
const roleValidation = validRoleSelection(currUser, newUserParams);
if (!roleValidation.valid) {
response
.status(200)
.json({ user: null, error: roleValidation.error });
return;View on GitHub (pinned to 526360e320)
Solutions
- Read the server console output — the console.error(e) prints the real stack that produced the 500.
- Verify database connectivity and credentials (DATABASE_URL).
- Regenerate the Prisma client (`prisma generate`) if the schema changed, then restart.
- Confirm the migration is applied (`prisma migrate deploy`) and the users table exists.
Example fix
// before
} catch (e) {
console.error(e);
response.sendStatus(500).end();
}
// after (richer response for diagnosis)
} catch (e) {
console.error('GET /admin/users failed:', e);
response.status(500).json({ error: 'Internal Server Error', requestId: req.id });
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!await canReachDatabase()) return res.status(503).json({ error: 'Database unavailable' }); Try / catch
try {
const users = await User.where();
res.status(200).json({ users });
} catch (e) {
console.error('GET /admin/users failed:', e);
res.status(500).json({ error: 'Internal Server Error' });
} Prevention
- Add a DB healthcheck that fails fast before serving admin routes.
- Keep Prisma client in sync with the schema (prisma generate + migrate deploy).
- Log a correlation id with each 500 so the console stack is traceable.
When it happens
Trigger: Database is unreachable or the connection pool exhausted; a Prisma migration mismatch (schema vs runtime); a corrupt users table; an auth/session helper throwing before the query. The 500 is a symptom — the real cause is in the server logs (console.error output).
Common situations: First request after a bad deploy where the DB schema drifted; Prisma client not regenerated after a schema change; DB credentials rotated but server not restarted; heavy load exhausting the connection pool.
Understand the failure class
- HTTP status errors: handling 4xx and 5xx responses — how to handle 4xx and 5xx responses properly.
Related errors
- Failed to update default system prompt.
- Internal Server Error
- Internal Server Error
- Internal Server Error
- Internal Server Error
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/768dd01c4e311a52.
Report an issue: GitHub.