{"record":{"id":"01a2049e7c7e381b","repo":"Mintplex-Labs/anything-llm","slug":"internal-server-error-01a204","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/api/userManagement/index.js","lineNumber":63,"sourceCode":"      description: \"Instance is not in Multi-User mode. Permission denied.\",\n    }\n      */\n    try {\n      if (!multiUserMode(response))\n        return response\n          .status(401)\n          .send(\"Instance is not in Multi-User mode. Permission denied.\");\n\n      const users = await User.where();\n      const filteredUsers = users.map((user) => ({\n        id: user.id,\n        username: user.username,\n        role: user.role,\n      }));\n      response.status(200).json({ users: filteredUsers });\n    } catch (e) {\n      console.error(e.message, e);\n      response.sendStatus(500).end();\n    }\n  });\n\n  app.get(\n    \"/v1/users/:id/issue-auth-token\",\n    [validApiKey, simpleSSOEnabled],\n    async (request, response) => {\n      /*\n      #swagger.tags = ['User Management']\n      #swagger.description = 'Issue a temporary auth token for a user'\n      #swagger.parameters['id'] = {\n        in: 'path',\n        description: 'The ID of the user to issue a temporary auth token for',\n        required: true,\n        type: 'string'\n      }\n      #swagger.responses[200] = {\n        content: {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/endpoints/api/userManagement/index.js#L45-L81","documentation":"Returned by GET /v1/users when User.where() throws after the multiUserMode gate passes. The handler at server/endpoints/api/userManagement/index.js:61 catches any exception from the Prisma query that loads all users. Since the multiUserMode check already passed (meaning the system is properly configured for multi-user), the throw is almost always a database-level issue: Prisma connection failure, schema drift, or a corrupt users table.","triggerScenarios":"GET /v1/users when the database connection has dropped or the Prisma client cannot reach the database server. Also triggered if the Prisma schema has been migrated but the client was not regenerated (prisma generate), causing a mismatch between the expected and actual table structure. In containerized deployments, this happens when the DB container is restarting or the DATABASE_URL points to an unreachable host.","commonSituations":"Database container restart or network partition between the app and database. Running a new code version against an old database without running migrations. The DATABASE_URL environment variable is incorrect or the database credentials have expired. Prisma client generated against a different schema version than the running database.","solutions":["Verify database connectivity: ensure DATABASE_URL is correct and the database host is reachable from the app container.","Run `npx prisma migrate deploy` (or the project's migration command) to ensure the schema is up to date.","Run `npx prisma generate` to regenerate the Prisma client after any schema change.","Check server logs for the specific Prisma error code (P1001 for connection failure, P2021 for missing table, etc.).","If using Docker, verify the database service is healthy before starting the app: `docker compose ps`."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const res = await fetch('/v1/users', {\n    headers: { Authorization: `Bearer ${API_KEY}` }\n  });\n  if (res.status === 401) throw new Error('Instance is not in Multi-User mode');\n  if (res.status === 500) throw new Error('Database error — check DB connectivity and Prisma migrations');\n  return await res.json();\n} catch (e) {\n  // Check DATABASE_URL and database health before retrying\n  console.error('Failed to list users:', e.message);\n}","preventionTips":["Always check for 401 first — it means multi-user mode is disabled, not a server error.","Ensure DATABASE_URL is correct and the database is running before making user management calls.","Run prisma migrate deploy after every AnythingLLM version upgrade.","Monitor database connection pool health in production."],"tags":["database","express","anythingllm","prisma","multi-user"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}