[PR #8982] [MERGED] chore: replace z.union with z.xor for permission schemas in admin plugin #25246

Closed
opened 2026-04-15 22:47:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8982
Author: @Saiyaswanthpasupuleti
Created: 4/6/2026
Status: Merged
Merged: 4/10/2026
Merged by: @bytaesu

Base: mainHead: fix/zod-handler-function


📝 Commits (7)

  • ba53845 refactor: replace z.union with z.xor for permission schemas in admin and organization routes
  • 96d29e8 Merge branch 'main' into fix/zod-handler-function
  • 9cd1e5c Merge branch 'main' into fix/zod-handler-function
  • 2b84a76 fix: enhance request validation for permission payloads by using z.xor instead of z.union (#8982)
  • 419b840 Merge branch 'main' into fix/zod-handler-function
  • affe13c chore: remove changeset
  • ee23113 Merge branch 'main' into fix/zod-handler-function

📊 Changes

2 files changed (+2 additions, -6 deletions)

View changed files

📝 packages/better-auth/src/plugins/admin/routes.ts (+1 -3)
📝 packages/better-auth/src/plugins/organization/organization.ts (+1 -3)

📄 Description

refactor: replace z.union with z.xor for permission schemas in admin and organization routes

Closes https://github.com/better-auth/better-auth/issues/8974


Summary by cubic

Tightened request validation for permission payloads by replacing z.union with z.xor. Requests must now include either permission or permissions (not both), with clearer errors.

  • Refactors
    • Swapped z.union for z.xor in admin userHasPermissionBodySchema and organization createHasPermissionBodySchema.
    • Removed explicit permission: undefined / permissions: undefined; exclusivity is now enforced by z.xor.

Written for commit ee23113ffd. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8982 **Author:** [@Saiyaswanthpasupuleti](https://github.com/Saiyaswanthpasupuleti) **Created:** 4/6/2026 **Status:** ✅ Merged **Merged:** 4/10/2026 **Merged by:** [@bytaesu](https://github.com/bytaesu) **Base:** `main` ← **Head:** `fix/zod-handler-function` --- ### 📝 Commits (7) - [`ba53845`](https://github.com/better-auth/better-auth/commit/ba53845ec54f17a61620565b11a9e84f16eae52f) refactor: replace z.union with z.xor for permission schemas in admin and organization routes - [`96d29e8`](https://github.com/better-auth/better-auth/commit/96d29e83a69bd7db6a2418b542eaa305297091c9) Merge branch 'main' into fix/zod-handler-function - [`9cd1e5c`](https://github.com/better-auth/better-auth/commit/9cd1e5cfbbab1d7f4ca0dfdf49b74267f0bb6244) Merge branch 'main' into fix/zod-handler-function - [`2b84a76`](https://github.com/better-auth/better-auth/commit/2b84a7689512aa9283c42f312df35a181bca27e5) fix: enhance request validation for permission payloads by using `z.xor` instead of `z.union` (#8982) - [`419b840`](https://github.com/better-auth/better-auth/commit/419b840b53bd7dd6f75e641264a8e0e4450c1d7b) Merge branch 'main' into fix/zod-handler-function - [`affe13c`](https://github.com/better-auth/better-auth/commit/affe13cba6834cd3198209d0e6a127d7878239e4) chore: remove changeset - [`ee23113`](https://github.com/better-auth/better-auth/commit/ee23113ffde2e67788c551c399894f455cda1567) Merge branch 'main' into fix/zod-handler-function ### 📊 Changes **2 files changed** (+2 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/admin/routes.ts` (+1 -3) 📝 `packages/better-auth/src/plugins/organization/organization.ts` (+1 -3) </details> ### 📄 Description refactor: replace z.union with z.xor for permission schemas in admin and organization routes Closes https://github.com/better-auth/better-auth/issues/8974 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Tightened request validation for permission payloads by replacing `z.union` with `z.xor`. Requests must now include either `permission` or `permissions` (not both), with clearer errors. - **Refactors** - Swapped `z.union` for `z.xor` in admin `userHasPermissionBodySchema` and organization `createHasPermissionBodySchema`. - Removed explicit `permission: undefined` / `permissions: undefined`; exclusivity is now enforced by `z.xor`. <sup>Written for commit ee23113ffde2e67788c551c399894f455cda1567. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 22:47:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#25246