get-full-organization endpoint is returning a 500 error on Prisma 7.1 #2522

Closed
opened 2026-03-13 10:00:42 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @ceolinwill on GitHub (Dec 13, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Add the next.js integration
  2. Add the Prisma adapter
  3. Call authClient.useActiveOrganization()

Current vs. Expected behavior

Current behavior

It throws the following error causing /api/auth/organization/get-full-organization to return a 500 error:

ERROR [Better Auth]: PrismaClientValidationError Error [PrismaClie
ntValidationError]: 
Invalid `db[model].findMany()` invocation in
/Users/will/coding/zoonk/zoonk/apps/editor/.next/dev/server/chunks/9fd60_better-auth_dist_a
983c6d2._.js:177:52

  174     map.set(key, getModelName(joinModel));
  175 }
  176 const selects = convertSelect(void 0, model, join);
→ 177 const result = await db[model].findMany({
        where: {
          id: {
            in: [
              1,
              2,
              3
            ]
          }
        },
        skip: 0,
        select: undefined,
      + take: Int
      })

Argument `take` is missing.
    at ignore-listed frames {
  clientVersion: '7.1.0'
}
# SERVER_ERROR:  Error [PrismaClientValidationError]: 
Invalid `db[model].findMany()` invocation in

Expected behavior

No errors

What version of Better Auth are you using?

1.4.6

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:56 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T8132",
    "release": "25.1.0",
    "cpuCount": 10,
    "cpuModel": "Apple M4",
    "totalMemory": "16.00 GB",
    "freeMemory": "0.16 GB"
  },
  "node": {
    "version": "v24.11.1",
    "env": "development"
  },
  "packageManager": {
    "name": "pnpm",
    "version": "10.24.0"
  },
  "frameworks": null,
  "databases": null,
  "betterAuth": {"version":"1.4.6","config":{"account":{"accountLinking":{"enabled":true}},"advanced":{"database":{"generateId":"serial"}},"appName":"Zoonk","experimental":{"joins":true},"rateLimit":{"enabled":true,"storage":"database"},"session":{"cookieCache":{"enabled":true,"maxAge":3600},"expiresIn":2592000},"trustedOrigins":["https://appleid.apple.com"],"plugins":[{"name":"admin","config":{"id":"admin","hooks":{"after":[{}]},"endpoints":{},"$ERROR_CODES":{},"schema":{"user":{"fields":{"role":{"type":"string","required":false,"input":false},"banned":{"type":"boolean","defaultValue":false,"required":false,"input":false},"banReason":{"type":"string","required":false,"input":false},"banExpires":{"type":"date","required":false,"input":false}}},"session":{"fields":{"impersonatedBy":{"type":"string","required":false}}}}}},{"name":"organization","config":{"id":"organization","endpoints":{},"schema":{"organization":{"fields":{"name":{"type":"string","required":true,"sortable":true},"slug":{"type":"string","required":true,"unique":true,"sortable":true},"logo":{"type":"string","required":false},"createdAt":{"type":"date","required":true},"metadata":{"type":"string","required":false},"kind":{"defaultValue":"brand","required":true,"type":"string"}}},"member":{"fields":{"organizationId":{"type":"string","required":true,"references":{"model":"organization","field":"id"},"index":true},"userId":{"type":"string","required":true,"references":{"model":"user","field":"id"},"index":true},"role":{"type":"string","required":true,"sortable":true,"defaultValue":"member"},"createdAt":{"type":"date","required":true}}},"invitation":{"fields":{"organizationId":{"type":"string","required":true,"references":{"model":"organization","field":"id"},"index":true},"email":{"type":"string","required":true,"sortable":true,"index":true},"role":{"type":"string","required":false,"sortable":true},"status":{"type":"string","required":true,"sortable":true,"defaultValue":"pending"},"expiresAt":{"type":"date","required":true},"createdAt":{"type":"date","required":true},"inviterId":{"type":"string","references":{"model":"user","field":"id"},"required":true}}},"session":{"fields":{"activeOrganizationId":{"type":"string","required":false}}}},"$Infer":{"Organization":{},"Invitation":{},"Member":{},"Team":{},"TeamMember":{},"ActiveOrganization":{}},"$ERROR_CODES":{},"options":{"allowUserToCreateOrganization":false,"membershipLimit":null,"organizationLimit":null,"roles":{"admin":{"statements":{"course":["create","read","update"],"organization":["update"],"invitation":["create","cancel"],"member":["create","update","delete"],"team":["create","update","delete"]}},"member":{"statements":{"course":["read"],"organization":[],"member":[],"invitation":[],"team":[]}},"owner":{"statements":{"course":["create","read","update","delete"],"organization":["update","delete"],"member":["create","update","delete"],"invitation":["create","cancel"],"team":["create","update","delete"]}}},"schema":{"organization":{"additionalFields":{"kind":{"defaultValue":"brand","required":true,"type":"string"}}}}}}},{"name":"next-cookies","config":{"id":"next-cookies","hooks":{"after":[{}]}}}],"socialProviders":{}}}
}

Which area(s) are affected? (Select all that apply)

Backend, Other, Client

Auth config (if applicable)


Additional context

No response

Originally created by @ceolinwill on GitHub (Dec 13, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Add the next.js integration 2. Add the Prisma adapter 3. Call `authClient.useActiveOrganization()` ### Current vs. Expected behavior ## Current behavior It throws the following error causing `/api/auth/organization/get-full-organization` to return a 500 error: ``` ERROR [Better Auth]: PrismaClientValidationError Error [PrismaClie ntValidationError]: Invalid `db[model].findMany()` invocation in /Users/will/coding/zoonk/zoonk/apps/editor/.next/dev/server/chunks/9fd60_better-auth_dist_a 983c6d2._.js:177:52 174 map.set(key, getModelName(joinModel)); 175 } 176 const selects = convertSelect(void 0, model, join); → 177 const result = await db[model].findMany({ where: { id: { in: [ 1, 2, 3 ] } }, skip: 0, select: undefined, + take: Int }) Argument `take` is missing. at ignore-listed frames { clientVersion: '7.1.0' } # SERVER_ERROR: Error [PrismaClientValidationError]: Invalid `db[model].findMany()` invocation in ``` ## Expected behavior No errors ### What version of Better Auth are you using? 1.4.6 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:56 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T8132", "release": "25.1.0", "cpuCount": 10, "cpuModel": "Apple M4", "totalMemory": "16.00 GB", "freeMemory": "0.16 GB" }, "node": { "version": "v24.11.1", "env": "development" }, "packageManager": { "name": "pnpm", "version": "10.24.0" }, "frameworks": null, "databases": null, "betterAuth": {"version":"1.4.6","config":{"account":{"accountLinking":{"enabled":true}},"advanced":{"database":{"generateId":"serial"}},"appName":"Zoonk","experimental":{"joins":true},"rateLimit":{"enabled":true,"storage":"database"},"session":{"cookieCache":{"enabled":true,"maxAge":3600},"expiresIn":2592000},"trustedOrigins":["https://appleid.apple.com"],"plugins":[{"name":"admin","config":{"id":"admin","hooks":{"after":[{}]},"endpoints":{},"$ERROR_CODES":{},"schema":{"user":{"fields":{"role":{"type":"string","required":false,"input":false},"banned":{"type":"boolean","defaultValue":false,"required":false,"input":false},"banReason":{"type":"string","required":false,"input":false},"banExpires":{"type":"date","required":false,"input":false}}},"session":{"fields":{"impersonatedBy":{"type":"string","required":false}}}}}},{"name":"organization","config":{"id":"organization","endpoints":{},"schema":{"organization":{"fields":{"name":{"type":"string","required":true,"sortable":true},"slug":{"type":"string","required":true,"unique":true,"sortable":true},"logo":{"type":"string","required":false},"createdAt":{"type":"date","required":true},"metadata":{"type":"string","required":false},"kind":{"defaultValue":"brand","required":true,"type":"string"}}},"member":{"fields":{"organizationId":{"type":"string","required":true,"references":{"model":"organization","field":"id"},"index":true},"userId":{"type":"string","required":true,"references":{"model":"user","field":"id"},"index":true},"role":{"type":"string","required":true,"sortable":true,"defaultValue":"member"},"createdAt":{"type":"date","required":true}}},"invitation":{"fields":{"organizationId":{"type":"string","required":true,"references":{"model":"organization","field":"id"},"index":true},"email":{"type":"string","required":true,"sortable":true,"index":true},"role":{"type":"string","required":false,"sortable":true},"status":{"type":"string","required":true,"sortable":true,"defaultValue":"pending"},"expiresAt":{"type":"date","required":true},"createdAt":{"type":"date","required":true},"inviterId":{"type":"string","references":{"model":"user","field":"id"},"required":true}}},"session":{"fields":{"activeOrganizationId":{"type":"string","required":false}}}},"$Infer":{"Organization":{},"Invitation":{},"Member":{},"Team":{},"TeamMember":{},"ActiveOrganization":{}},"$ERROR_CODES":{},"options":{"allowUserToCreateOrganization":false,"membershipLimit":null,"organizationLimit":null,"roles":{"admin":{"statements":{"course":["create","read","update"],"organization":["update"],"invitation":["create","cancel"],"member":["create","update","delete"],"team":["create","update","delete"]}},"member":{"statements":{"course":["read"],"organization":[],"member":[],"invitation":[],"team":[]}},"owner":{"statements":{"course":["create","read","update","delete"],"organization":["update","delete"],"member":["create","update","delete"],"invitation":["create","cancel"],"team":["create","update","delete"]}}},"schema":{"organization":{"additionalFields":{"kind":{"defaultValue":"brand","required":true,"type":"string"}}}}}}},{"name":"next-cookies","config":{"id":"next-cookies","hooks":{"after":[{}]}}}],"socialProviders":{}}} } ``` ### Which area(s) are affected? (Select all that apply) Backend, Other, Client ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 10:00:42 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 13, 2025):

This 500 error is caused by a Prisma 7.1 validation change: findMany now requires the take argument, and Better Auth's Prisma adapter is supposed to always set it (defaulting to 100 if not provided). However, when experimental joins are enabled, a misconfiguration in your schema or join setup can cause the join/limit logic to break, resulting in Prisma receiving a query without take and throwing this error—even though the adapter code intends to always set it [adapter code].

Checklist to resolve:

  • Double-check that all model and field names in your Better Auth config exactly match your Prisma schema (case-sensitive).
  • Ensure all fields used in where clauses (especially id) are marked as @unique in your Prisma schema.
  • If you have recently changed your schema, run npx prisma generate to regenerate the client.
  • If you are using experimental joins, make sure all relations are correctly defined and mapped in your schema. Any mismatch or missing relation can cause join logic to fail and break query construction [details].
  • Try disabling experimental joins (experimental.joins: false) as a temporary workaround. If the error disappears, the root cause is almost certainly a join/schema config issue.

Extra troubleshooting:
Enable debug logs in your Better Auth Prisma adapter to see the exact query parameters being sent. This can help pinpoint where the join/limit logic is breaking down.

If you fix your schema and join config (or temporarily disable experimental joins), the error should go away. If you want to keep experimental joins enabled, regenerating your schema with the Better Auth CLI and ensuring all relations are present and correctly named is the most reliable fix [schema/join advice].

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 13, 2025): <!-- Answer --> This 500 error is caused by a Prisma 7.1 validation change: `findMany` now requires the `take` argument, and Better Auth's Prisma adapter is supposed to always set it (defaulting to 100 if not provided). However, when experimental joins are enabled, a misconfiguration in your schema or join setup can cause the join/limit logic to break, resulting in Prisma receiving a query without `take` and throwing this error—even though the adapter code intends to always set it [[adapter code](https://github.com/better-auth/better-auth/blob/3d849d8dbb7fb2673b50b3f9e12755d7ffbefa23/packages/better-auth/src/adapters/prisma-adapter/prisma-adapter.ts#L80-L340)]. **Checklist to resolve:** - Double-check that all model and field names in your Better Auth config exactly match your Prisma schema (case-sensitive). - Ensure all fields used in `where` clauses (especially `id`) are marked as `@unique` in your Prisma schema. - If you have recently changed your schema, run `npx prisma generate` to regenerate the client. - If you are using experimental joins, make sure all relations are correctly defined and mapped in your schema. Any mismatch or missing relation can cause join logic to fail and break query construction [[details](https://github.com/better-auth/better-auth/issues/6200#issuecomment-3567048079)]. - Try disabling experimental joins (`experimental.joins: false`) as a temporary workaround. If the error disappears, the root cause is almost certainly a join/schema config issue. **Extra troubleshooting:** Enable debug logs in your Better Auth Prisma adapter to see the exact query parameters being sent. This can help pinpoint where the join/limit logic is breaking down. If you fix your schema and join config (or temporarily disable experimental joins), the error should go away. If you want to keep experimental joins enabled, regenerating your schema with the Better Auth CLI and ensuring all relations are present and correctly named is the most reliable fix [[schema/join advice](https://github.com/better-auth/better-auth/issues/6200#issuecomment-3567048079)]. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/97ece2d0-3f74-4200-a847-2c46f1631386?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/97ece2d0-3f74-4200-a847-2c46f1631386?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/97ece2d0-3f74-4200-a847-2c46f1631386?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/97ece2d0-3f74-4200-a847-2c46f1631386?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/97ece2d0-3f74-4200-a847-2c46f1631386?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/97ece2d0-3f74-4200-a847-2c46f1631386?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/97ece2d0-3f74-4200-a847-2c46f1631386?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20500%20error%20is%20caused%20by%20a%20Prisma%207.1%20validation%20change%3A%20%60findMany%60%20now%20requires%20the%20%60take%60%20argument%2C%20and%20Better%20Auth%27s%20Prisma%20adapter%20is%20supposed%20to%20always%20set%20it%20%28defaulting%20to%20100%20if%20not%20provided%29.%20However%2C%20when%20experimental%20joins%20are%20enabled%2C%20a%20misconfiguration%20in%20your%20schema%20or%20join%20setup%20can%20cause%20the%20join/limit%20logic%20to%20break%2C%20resulting%20in%20Prisma%20receiving%20a%20query%20without%20%60take%60%20and%20throwing%20this%20error%E2%80%94even%20though%20the%20adapter%20code%20intends%20to%20always%20set%20it%20%5B%5Badapter%20code%5D%28https%3A//github.com/better-auth/better-auth/blob/3d849d8dbb7fb2673b50b3f9e12755d7ffbefa23/packages/better-auth/src/adapters/prisma-adapter/prisma-adapter.ts%23L80-L340%29%5D.%0A%0A%2A%2AChecklist%20to%20resolve%3A%2A%2A%0A-%20Double-check%20that%20all%20model%20and%20field%20names%20in%20your%20Better%20Auth%20config%20exactly%20match%20your%20Prisma%20schema%20%28case-sensitive%29.%0A-%20Ensure%20all%20fields%20used%20in%20%60where%60%20clauses%20%28especially%20%60id%60%29%20are%20marked%20as%20%60%40unique%60%20in%20your%20Prisma%20schema.%0A-%20If%20you%20have%20recently%20changed%20your%20schema%2C%20run%20%60npx%20prisma%20generate%60%20to%20regenerate%20the%20client.%0A-%20If%20you%20are%20using%20experimental%20joins%2C%20make%20sure%20all%20relations%20are%20correctly%20defined%20and%20mapped%20in%20your%20schema.%20Any%20mismatch%20or%20missing%20relation%20can%20cause%20join%20logic%20to%20fail%20and%20break%20query%20construction%20%5B%5Bdetails%5D%28https%3A//github.com/better-auth/better-auth/issues/6200%23issuecomment-3567048079%29%5D.%0A-%20Try%20disabling%20experimental%20joins%20%28%60experimental.joins%3A%20false%60%29%20as%20a%20temporary%20workaround.%20If%20the%20error%20disappears%2C%20the%20root%20cause%20is%20almost%20certainly%20a%20join/schema%20config%20issue.%0A%0A%2A%2AExtra%20troubleshooting%3A%2A%2A%20%20%0AEnable%20debug%20logs%20in%20your%20Better%20Auth%20Prisma%20adapter%20to%20see%20the%20exact%20query%20parameters%20being%20sent.%20This%20can%20help%20pinpoint%20where%20the%20join/limit%20logic%20is%20breaking%20down.%0A%0AIf%20you%20fix%20your%20schema%20and%20join%20config%20%28or%20temporarily%20disable%20experimental%20joins%29%2C%20the%20error%20should%20go%20away.%20If%20you%20want%20to%20keep%20experimental%20joins%20enabled%2C%20regenerating%20your%20schema%20with%20the%20Better%20Auth%20CLI%20and%20ensuring%20all%20relations%20are%20present%20and%20correctly%20named%20is%20the%20most%20reliable%20fix%20%5B%5Bschema/join%20advice%5D%28https%3A//github.com/better-auth/better-auth/issues/6200%23issuecomment-3567048079%29%5D.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/6739)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2522