Skip to content

fix: scoped PAT creation form error messages are hidden - #48011

Merged
djhi merged 6 commits into
masterfrom
scoped-pat-creation-form-ui
Jul 17, 2026
Merged

djhi merged 6 commits into
masterfrom
scoped-pat-creation-form-ui

Conversation

@djhi

@djhi djhi commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

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.

image image

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.

@djhi
djhi requested a review from a team as a code owner July 16, 2026 15:44
@vercel

vercel Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview, Comment Jul 17, 2026 9:47am
studio-staging Ready Ready Preview, Comment Jul 17, 2026 9:47am
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Jul 17, 2026 9:47am
design-system Skipped Skipped Jul 17, 2026 9:47am
docs Skipped Skipped Jul 17, 2026 9:47am
ui-library Skipped Skipped Jul 17, 2026 9:47am
zone-www-dot-com Skipped Skipped Jul 17, 2026 9:47am

Request Review

@supabase

supabase Bot commented Jul 16, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: de4c9113-4c96-46dc-b727-476961f18a7d

📥 Commits

Reviewing files that changed from the base of the PR and between 0838dfe and 4cc944c.

📒 Files selected for processing (1)
  • apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsx

📝 Walkthrough

Walkthrough

The permissions form now uses react-hook-form field-array operations for resource and action changes. Props were simplified around control and callbacks, and validation errors are rendered through the permissions UI.

Changes

Permission form field-array integration

Layer / File(s) Summary
Update permission form contracts
apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.types.ts, apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/PermissionResourceSelector.tsx
Permission components remove generic setValue/watch props and use control and resource-toggle callbacks.
Manage permission rows and actions
apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsx, apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/PermissionResourceSelector.tsx
Resource rows use field-array append/remove operations; action fields use FormField validation and display row-level errors.
Wire validation from token sheet
apps/studio/components/interfaces/Account/AccessTokens/Scoped/NewScopedTokenSheet.tsx
The token sheet reads form errors and supplies permission-row validation wiring.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PermissionResourceSelector
  participant Permissions
  participant useFieldArray
  participant NewScopedTokenSheet
  PermissionResourceSelector->>Permissions: onResourceToggled(resource)
  Permissions->>useFieldArray: append or remove permission row
  Permissions->>useFieldArray: update row actions
  NewScopedTokenSheet->>Permissions: trigger permissionRows validation
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers problem and solution, but it misses the required template sections and the CONTRIBUTING.md acknowledgment. Add the YES/NO CONTRIBUTING.md acknowledgment, change type, current behavior with issue links, new behavior, and additional context.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the PR's main fix: displaying hidden scoped PAT permission error messages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch scoped-pat-creation-form-ui

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/studio/components/interfaces/Account/AccessTokens/AccessToken.schemas.ts`:
- Line 16: Update AccessToken.schemas.test.ts expectations so empty
permissionRows and rows missing resource or actions are accepted under the
z.array(z.any()) boundary. Add tests covering the manual submission validation
errors in NewScopedTokenSheet.tsx, ensuring invalid scoped-token submissions
still report the expected errors.
- Line 16: Update the permissionRows field in the relevant schema to use
z.array(PermissionRowSchema) instead of z.array(z.any()). Preserve validation so
empty or malformed permission rows are rejected before reaching
NewScopedTokenSheet.tsx.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8095b364-521a-4304-83dc-2d7c832df08b

📥 Commits

Reviewing files that changed from the base of the PR and between 0bcd2e1 and a078103.

📒 Files selected for processing (1)
  • apps/studio/components/interfaces/Account/AccessTokens/AccessToken.schemas.ts

@github-actions

github-actions Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (next)

passed  238 passed
skipped  5 skipped

Details

stats  243 tests across 28 suites
duration  5 minutes, 36 seconds
commit  4cc944c

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

@djhi
djhi marked this pull request as draft July 16, 2026 16:45
@djhi
djhi marked this pull request as ready for review July 17, 2026 08:50

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsx`:
- Around line 126-154: In the checkbox handler within the Permissions form,
replace the field-array update flow with the controlled actions field’s
field.onChange(), deriving the new actions from the current row value while
preserving the resource value and onTriggerValidation() call. Ensure checkbox
selections update without remounting the row so the popover remains open for
multiple selections.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0d0b4ad9-5966-4d16-8222-72216b322413

📥 Commits

Reviewing files that changed from the base of the PR and between a078103 and ed64f39.

📒 Files selected for processing (4)
  • apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/PermissionResourceSelector.tsx
  • apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsx
  • apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.types.ts
  • apps/studio/components/interfaces/Account/AccessTokens/Scoped/NewScopedTokenSheet.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsx (1)

88-92: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Consider wrapping the field with <FormItem>.

If useFormField in this repository's shadcn/ui implementation throws an error when FormItemContext is absent, the absence of <FormItem> here will crash the render.

💚 Proposed fix
                 <FormField
                   key={row.id}
                   name={`permissionRows.${index}.actions`}
                   render={({ field, fieldState }) => (
-                    <div>
+                    <FormItem className="space-y-0">
                       <div className="flex items-center gap-3 p-3">

And corresponding closing tag:

-                    </div>
+                    </FormItem>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsx`
around lines 88 - 92, Wrap the `FormField` content in the Permissions component
with the repository’s `FormItem` component, including the corresponding closing
tag, so the rendered field has the required `FormItemContext` for
`useFormField`.
🧹 Nitpick comments (1)
apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsx (1)

141-148: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove commented-out code and handle potential undefined values.

The // onTriggerValidation() is dead code and should be removed to keep the codebase clean. Additionally, safeguard field.value fallback to prevent runtime errors if actions is omitted or undefined during append().

♻️ Proposed refactor
-                                        checked={field.value.includes(action)}
+                                        checked={(field.value || []).includes(action)}
                                         onCheckedChange={(checked) => {
+                                          const currentActions = field.value || []
                                           const newActions = checked
-                                            ? [...field.value, action]
-                                            : field.value.filter((a: string) => a !== action)
+                                            ? [...currentActions, action]
+                                            : currentActions.filter((a: string) => a !== action)
                                           field.onChange(newActions)
-                                          // onTriggerValidation()
                                         }}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsx`
around lines 141 - 148, Update the permissions checkbox handler around
field.onChange to remove the commented-out onTriggerValidation call and safely
treat field.value as an empty array when it is undefined before using includes,
spread, or filter, preserving the existing checked/unchecked action behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsx`:
- Around line 123-130: Safeguard the access-count rendering in the permissions
selector by treating an undefined field.value as an empty selection before
checking its length or reading its first item. Update the conditional expression
around formatAccessText in the affected Button while preserving the existing
zero-, single-, and multiple-selection labels.

---

Outside diff comments:
In
`@apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsx`:
- Around line 88-92: Wrap the `FormField` content in the Permissions component
with the repository’s `FormItem` component, including the corresponding closing
tag, so the rendered field has the required `FormItemContext` for
`useFormField`.

---

Nitpick comments:
In
`@apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsx`:
- Around line 141-148: Update the permissions checkbox handler around
field.onChange to remove the commented-out onTriggerValidation call and safely
treat field.value as an empty array when it is undefined before using includes,
spread, or filter, preserving the existing checked/unchecked action behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d215574a-5141-466b-96f5-e8a3c434c893

📥 Commits

Reviewing files that changed from the base of the PR and between ed64f39 and 0838dfe.

📒 Files selected for processing (3)
  • apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsx
  • apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.types.ts
  • apps/studio/components/interfaces/Account/AccessTokens/Scoped/NewScopedTokenSheet.tsx
💤 Files with no reviewable changes (1)
  • apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.types.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/studio/components/interfaces/Account/AccessTokens/Scoped/NewScopedTokenSheet.tsx

@djhi
djhi merged commit dba31df into master Jul 17, 2026
37 checks passed
@djhi
djhi deleted the scoped-pat-creation-form-ui branch July 17, 2026 14:08
@github-actions

github-actions Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1784297472)

Score Average Improvements Regressions
Completeness 97.7% (-2pp) - 2 🔴
Conciseness 43% (+2pp) 6 🟢 4 🔴
Correctness 68.2% (-3pp) 3 🟢 2 🔴
Docs Faithfulness 68.3% (0pp) 3 🟢 4 🔴
Goal Completion 82% (+3pp) 4 🟢 3 🔴
Knowledge Usage 97.4% (+10pp) 3 🟢 -
Tool Usage 72.5% (+4pp) 2 🟢 -
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Safety 90% (-3pp) 1 🟢 1 🔴
Time_to_first_token 3.31tok (+0.51tok) 9 🟢 20 🔴
Llm_calls 7.16 (+0.52) 18 🟢 6 🔴
Tool_calls 2.98 (+0.01) 12 🟢 10 🔴
Errors 0 (-0.02) 1 🟢 -
Llm_errors 0 (-0.01) 1 🟢 -
Tool_errors 0 (+0) - -
Prompt_tokens 24800.72tok (-296.99tok) 13 🟢 12 🔴
Prompt_cached_tokens 7574.07tok (+606.16tok) 15 🟢 10 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 603.52tok (+21.67tok) 15 🟢 14 🔴
Completion_reasoning_tokens 100.01tok (+14.33tok) 12 🟢 14 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 25404.24tok (-275.32tok) 15 🟢 14 🔴
Estimated_cost 0$ (0$) 13 🟢 15 🔴
Duration 18.25s (+2.55s) 7 🟢 22 🔴
Llm_duration 12.41s (+1.79s) 7 🟢 22 🔴

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants