Repository navigation
fix: scoped PAT creation form error messages are hidden - #48011
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe permissions form now uses ChangesPermission form field-array integration
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
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
apps/studio/components/interfaces/Account/AccessTokens/AccessToken.schemas.ts
🎭 Playwright Test Results (next)Details
Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
There was a problem hiding this comment.
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
📒 Files selected for processing (4)
apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/PermissionResourceSelector.tsxapps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsxapps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.types.tsapps/studio/components/interfaces/Account/AccessTokens/Scoped/NewScopedTokenSheet.tsx
There was a problem hiding this comment.
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 winConsider wrapping the field with
<FormItem>.If
useFormFieldin this repository'sshadcn/uiimplementation throws an error whenFormItemContextis 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 valueRemove commented-out code and handle potential undefined values.
The
// onTriggerValidation()is dead code and should be removed to keep the codebase clean. Additionally, safeguardfield.valuefallback to prevent runtime errors ifactionsis omitted or undefined duringappend().♻️ 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
📒 Files selected for processing (3)
apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.tsxapps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/Permissions/Permissions.types.tsapps/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
Braintrust eval report
|
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