{"record":{"id":"6cf440949ae6b30d","repo":"Mintplex-Labs/anything-llm","slug":"internal-server-error-6cf440","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/api/admin/index.js","lineNumber":81,"sourceCode":"      schema: {\n        \"$ref\": \"#/definitions/InvalidAPIKey\"\n      }\n    }\n     #swagger.responses[401] = {\n      description: \"Instance is not in Multi-User mode. Method denied\",\n    }\n    */\n    try {\n      if (!multiUserMode(response)) {\n        response.sendStatus(401).end();\n        return;\n      }\n\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  app.post(\"/v1/admin/users/new\", [validApiKey], async (request, response) => {\n    /*\n    #swagger.tags = ['Admin']\n    #swagger.description = 'Create a new user with username and password. Methods are disabled until multi user mode is enabled via the UI.'\n    #swagger.requestBody = {\n        description: 'Key pair object that will define the new user to add to the system.',\n        required: true,\n        content: {\n          \"application/json\": {\n            example: {\n              username: \"sample-sam\",\n              password: 'hunter2',\n              role: 'default | admin'\n            }\n          }","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/endpoints/api/admin/index.js#L63-L99","documentation":"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.","triggerScenarios":"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.","commonSituations":"Post-migration prisma client not regenerated; a partial migration that did not create the users table; concurrent heavy writes locking the table.","solutions":["Read server logs for the SQL error printed by console.error(e).","Run pending migrations and regenerate the ORM client (npx prisma generate / migrate deploy).","Confirm the users table exists and the API key used has not been revoked between auth and the query.","If the user count is very large, paginate the listing rather than returning all rows at once."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const users = await User.where();\n  response.status(200).json({ users });\n} catch (e) {\n  console.error('GET /v1/admin/users failed:', e);\n  response.status(503).json({ users:[], error:'User listing unavailable' });\n}","preventionTips":["Keep migrations in sync so the users table matches the ORM schema.","Regenerate the prisma client after schema changes.","Monitor DB connectivity for the lifetime of the request, not only at auth time."],"tags":["express","api","admin-api","users","database","schema-migration"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}