{"record":{"id":"ba634d710ad50600","repo":"Mintplex-Labs/anything-llm","slug":"internal-server-error-ba634d","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/mobile/index.js","lineNumber":30,"sourceCode":"  if (!app) return;\n\n  /**\n   * Gets all the devices from the database.\n   * @param {import(\"express\").Request} request\n   * @param {import(\"express\").Response} response\n   */\n  app.get(\n    \"/mobile/devices\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (_request, response) => {\n      try {\n        const devices = await MobileDevice.where({}, null, null, {\n          user: { select: { id: true, username: true } },\n        });\n        return response.status(200).json({ devices });\n      } catch (e) {\n        console.error(e);\n        response.sendStatus(500).end();\n      }\n    }\n  );\n\n  /**\n   * Updates the device status via an updates object.\n   * @param {import(\"express\").Request} request\n   * @param {import(\"express\").Response} response\n   */\n  app.post(\n    \"/mobile/update/:id\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (request, response) => {\n      try {\n        const body = reqBody(request);\n        const updates = await MobileDevice.update(\n          Number(request.params.id),\n          body","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/endpoints/mobile/index.js#L12-L48","documentation":"Generic catch-all in GET /mobile/devices. Calls MobileDevice.where with a Prisma include for the user relation. The model's where method has an internal try-catch returning [], so this 500 fires from a Prisma relation error (the 'user' include does not match the schema) or a total DB outage that bypasses the inner catch.","triggerScenarios":"Calling GET /mobile/devices after a schema change where the desktop_mobile_devices model no longer has a 'user' relation defined in the Prisma schema, or when the Prisma client was not regenerated after a migration that added/renamed the relation.","commonSituations":"Post-migration without running npx prisma generate, schema drift between the database and the Prisma schema file, or a Prisma version upgrade that changed relation include syntax.","solutions":["Run npx prisma generate to regenerate the client after any schema change.","Verify the desktop_mobile_devices model has a user relation in schema.prisma.","Check server logs for a Prisma validation error about unknown relation 'user'.","Run npx prisma migrate status to ensure migrations are in sync."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// The handler already has a catch; focus on schema sync\ncatch (e) {\n  console.error(\"GET /mobile/devices failed:\", e);\n  if (e?.message?.includes(\"relation\") || e?.code === \"P2009\") {\n    return response.status(500).json({ error: \"Schema mismatch — run prisma generate.\" });\n  }\n  response.sendStatus(500).end();\n}","preventionTips":["Always run npx prisma generate after modifying schema.prisma.","Include a Prisma relation check in CI: verify the generated client has expected relations.","Use npx prisma migrate status in deployment scripts to catch pending migrations."],"tags":["express","mobile","prisma","schema-mismatch","database"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}