From dba31df91d82da2897dc69e367c29e09a122d0c1 Mon Sep 17 00:00:00 2001
From: Gildas Garcia <1122076+djhi@users.noreply.github.com>
Date: Fri, 17 Jul 2026 16:08:13 +0200
Subject: [PATCH] fix: scoped PAT creation form error messages are hidden
(#48011)
## Problem
When creating a new scoped PAT, if users didn't add at least one
permission or have a misconfigured permission (no access selected), the
form does not submit but no error message is shown. The UI looks broken.
## Solution
This is because there's a zod validation happening but its messages are
not displayed for permissions.
The proper fix is to use react-hook-form field array.
## Summary by CodeRabbit
* **Bug Fixes**
* Improved permission selection and toggling behavior in the scoped
access token flow.
* Enhanced validation feedback for permission rows and action
selections, keeping error states in sync after changes.
* Updated error handling to surface permission-related messages more
reliably.
* **Refactor**
* Reworked the permissions UI to use a more reliable control-based
rendering approach for rows, selection changes, and error presentation.
---
.../PermissionResourceSelector.tsx | 27 +--
.../Scoped/Form/Permissions/Permissions.tsx | 229 ++++++++++--------
.../Form/Permissions/Permissions.types.ts | 15 +-
.../Scoped/NewScopedTokenSheet.tsx | 4 +-
4 files changed, 148 insertions(+), 127 deletions(-)
diff --git a/apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/PermissionResourceSelector.tsx b/apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/PermissionResourceSelector.tsx
index e0d823e77ee..79955c9ebce 100644
--- a/apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/PermissionResourceSelector.tsx
+++ b/apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/PermissionResourceSelector.tsx
@@ -1,5 +1,4 @@
import { Key, Plus } from 'lucide-react'
-import { Path, PathValue } from 'react-hook-form'
import {
Button,
Checkbox,
@@ -14,30 +13,16 @@ import {
PopoverTrigger,
} from 'ui'
-import {
- PermissionResource,
- PermissionResourceSelectorProps,
- PermissionRow,
- PermissionsFormValues,
-} from './Permissions.types'
-import { togglePermissionResource } from './Permissions.utils'
+import { PermissionResourceSelectorProps, PermissionRow } from './Permissions.types'
import { ACCESS_TOKEN_RESOURCES } from '@/components/interfaces/Account/AccessTokens/AccessToken.constants'
-export const PermissionResourceSelector = ({
+export const PermissionResourceSelector = ({
open,
onOpenChange,
+ onResourceToggled,
permissionRows,
- setValue,
align = 'center',
-}: PermissionResourceSelectorProps) => {
- const handleToggleResource = (resource: PermissionResource) => {
- const newRows = togglePermissionResource(permissionRows, resource)
- setValue(
- 'permissionRows' as Path,
- newRows as PathValue>
- )
- }
-
+}: PermissionResourceSelectorProps) => {
return (
@@ -61,13 +46,13 @@ export const PermissionResourceSelector = handleToggleResource(resource)}
+ onSelect={() => onResourceToggled(resource)}
className="text-foreground"
>