Mintplex-Labs/anything-llm · error

Internal Server Error

Error message

Internal Server Error

What it means

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.

Source

Thrown at server/endpoints/mobile/index.js:30

  if (!app) return;

  /**
   * Gets all the devices from the database.
   * @param {import("express").Request} request
   * @param {import("express").Response} response
   */
  app.get(
    "/mobile/devices",
    [validatedRequest, flexUserRoleValid([ROLES.admin])],
    async (_request, response) => {
      try {
        const devices = await MobileDevice.where({}, null, null, {
          user: { select: { id: true, username: true } },
        });
        return response.status(200).json({ devices });
      } catch (e) {
        console.error(e);
        response.sendStatus(500).end();
      }
    }
  );

  /**
   * Updates the device status via an updates object.
   * @param {import("express").Request} request
   * @param {import("express").Response} response
   */
  app.post(
    "/mobile/update/:id",
    [validatedRequest, flexUserRoleValid([ROLES.admin])],
    async (request, response) => {
      try {
        const body = reqBody(request);
        const updates = await MobileDevice.update(
          Number(request.params.id),
          body

View on GitHub (pinned to 526360e320)

Solutions

  1. Run npx prisma generate to regenerate the client after any schema change.
  2. Verify the desktop_mobile_devices model has a user relation in schema.prisma.
  3. Check server logs for a Prisma validation error about unknown relation 'user'.
  4. Run npx prisma migrate status to ensure migrations are in sync.
Defensive patterns

Strategy: try-catch

Try / catch

// The handler already has a catch; focus on schema sync
catch (e) {
  console.error("GET /mobile/devices failed:", e);
  if (e?.message?.includes("relation") || e?.code === "P2009") {
    return response.status(500).json({ error: "Schema mismatch — run prisma generate." });
  }
  response.sendStatus(500).end();
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/ba634d710ad50600. Report an issue: GitHub.