{"record":{"id":"312d2c01b77933b7","repo":"Mintplex-Labs/anything-llm","slug":"internal-server-error-312d2c","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/invite.js","lineNumber":33,"sourceCode":"      const invite = await Invite.get({ code });\n      if (!invite) {\n        response.status(200).json({ invite: null, error: \"Invite not found.\" });\n        return;\n      }\n\n      if (invite.status !== \"pending\") {\n        response\n          .status(200)\n          .json({ invite: null, error: \"Invite is no longer valid.\" });\n        return;\n      }\n\n      response\n        .status(200)\n        .json({ invite: { code, status: invite.status }, error: null });\n    } catch (e) {\n      console.error(e);\n      response.sendStatus(500).end();\n    }\n  });\n\n  app.post(\n    \"/invite/:code\",\n    [simpleSSOLoginDisabledMiddleware],\n    async (request, response) => {\n      try {\n        const { code } = request.params;\n        const { username, password } = reqBody(request);\n        const invite = await Invite.get({ code });\n        if (!invite || invite.status !== \"pending\") {\n          response\n            .status(200)\n            .json({ success: false, error: \"Invite not found or is invalid.\" });\n          return;\n        }\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/endpoints/invite.js#L15-L51","documentation":"Generic catch-all in the GET /invite/:code route handler. The handler calls Invite.get({code}) which has its own internal try-catch returning null on failure, then performs status checks and returns JSON. Because the model layer absorbs database errors, this 500 fires only from truly unexpected exceptions — most commonly Prisma client not being initialized, connection pool exhaustion, or a response serialization failure.","triggerScenarios":"Calling GET /invite/:code when the Prisma client failed to connect to the database (the inner catch in Invite.get logs but returns null, so a total DB outage usually yields a 200 with {invite: null} — the 500 requires an error outside that inner catch, such as the Prisma client object itself being undefined, or a middleware-level response conflict).","commonSituations":"Database server down or unreachable at startup but the Node process continued running, Prisma client initialization race condition during hot-reload in development, or SQLite file lock contention in single-user mode.","solutions":["Check server logs — the console.error(e) prints the underlying exception.","Verify database connectivity (Prisma Studio or a direct connection test).","Ensure the Prisma client was generated (npx prisma generate) and the DATABASE_URL is correct.","If using SQLite, check for file permission or lock issues on the database file."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate invite code format before DB lookup\nconst { code } = request.params;\nif (!code || typeof code !== \"string\" || code.length < 10) {\n  return response.status(200).json({ invite: null, error: \"Invalid invite code.\" });\n}","typeGuard":null,"tryCatchPattern":"// The handler already has a catch; add a DB health check\ncatch (e) {\n  console.error(\"GET /invite/:code failed:\", e);\n  if (e.message?.includes(\"Prisma\")) {\n    return response.status(503).json({ error: \"Database unavailable.\" });\n  }\n  response.sendStatus(500).end();\n}","preventionTips":["Monitor database connection health with a periodic ping.","Ensure Prisma client is generated as part of the build step.","Use a connection pooler for PostgreSQL in production."],"tags":["express","prisma","invites","database"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}