{"record":{"id":"8bffe614fd0ef866","repo":"Mintplex-Labs/anything-llm","slug":"internal-server-error-8bffe6","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/modelRouter.js","lineNumber":24,"sourceCode":"const {\n  flexUserRoleValid,\n  ROLES,\n} = require(\"../utils/middleware/multiUserProtected\");\nconst { validatedRequest } = require(\"../utils/middleware/validatedRequest\");\n\nfunction modelRouterEndpoints(app) {\n  if (!app) return;\n\n  app.get(\n    \"/model-routers\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (_request, response) => {\n      try {\n        const routers = await ModelRouter.getAllWithCounts();\n        response.status(200).json({ routers });\n      } catch (e) {\n        console.error(e);\n        response.sendStatus(500);\n      }\n    }\n  );\n\n  app.get(\n    \"/model-routers/:id\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (request, response) => {\n      try {\n        const { id } = request.params;\n        const router = await ModelRouter.getWithRulesAndCount({\n          id: Number(id),\n        });\n        if (!router) {\n          response\n            .status(404)\n            .json({ router: null, error: \"Router not found.\" });\n          return;","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/endpoints/modelRouter.js#L6-L42","documentation":"Generic catch-all in GET /model-routers. Calls ModelRouter.getAllWithCounts which has a comprehensive internal try-catch returning []. The 500 fires only from infrastructure-level failures that prevent the model's inner catch from executing, such as the Prisma client module not loading correctly.","triggerScenarios":"Calling GET /model-routers when the Prisma client was not generated or the database is completely unreachable at a level below the Prisma query layer.","commonSituations":"Missing npx prisma generate step after deployment, database server not started, or the model_routers table not existing due to a pending migration.","solutions":["Run npx prisma generate and npx prisma migrate deploy.","Verify database connectivity.","Check server logs for the specific Prisma or module-loading error.","Ensure the model_routers table exists in the database."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run npx prisma generate as a postinstall or build step.","Run npx prisma migrate deploy before starting the server.","Add a database health check endpoint to detect connectivity issues early."],"tags":["express","model-router","prisma","database","admin-only"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}