{"record":{"id":"768dd01c4e311a52","repo":"Mintplex-Labs/anything-llm","slug":"internal-server-error","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/admin.js","lineNumber":47,"sourceCode":"  simpleSSOLoginDisabledMiddleware,\n} = require(\"../utils/middleware/simpleSSOEnabled\");\nconst {\n  workspaceDeletionProtection,\n} = require(\"../utils/middleware/workspaceDeletionProtection\");\n\nfunction adminEndpoints(app) {\n  if (!app) return;\n\n  app.get(\n    \"/admin/users\",\n    [validatedRequest, strictMultiUserRoleValid([ROLES.admin, ROLES.manager])],\n    async (_request, response) => {\n      try {\n        const users = await User.where();\n        response.status(200).json({ users });\n      } catch (e) {\n        console.error(e);\n        response.sendStatus(500).end();\n      }\n    }\n  );\n\n  app.post(\n    \"/admin/users/new\",\n    [validatedRequest, strictMultiUserRoleValid([ROLES.admin, ROLES.manager])],\n    async (request, response) => {\n      try {\n        const currUser = await userFromSession(request, response);\n        const newUserParams = reqBody(request);\n        const roleValidation = validRoleSelection(currUser, newUserParams);\n\n        if (!roleValidation.valid) {\n          response\n            .status(200)\n            .json({ user: null, error: roleValidation.error });\n          return;","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/endpoints/admin.js#L29-L65","documentation":"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).","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\n} catch (e) {\n  console.error(e);\n  response.sendStatus(500).end();\n}\n\n// after (richer response for diagnosis)\n} catch (e) {\n  console.error('GET /admin/users failed:', e);\n  response.status(500).json({ error: 'Internal Server Error', requestId: req.id });\n}","handlingStrategy":"try-catch","validationCode":"if (!await canReachDatabase()) return res.status(503).json({ error: 'Database unavailable' });","typeGuard":null,"tryCatchPattern":"try {\n  const users = await User.where();\n  res.status(200).json({ users });\n} catch (e) {\n  console.error('GET /admin/users failed:', e);\n  res.status(500).json({ error: 'Internal Server Error' });\n}","preventionTips":["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."],"tags":["api","admin","database","http-500"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}