-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix(perms): copilot checks undefined issue #2763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile OverviewGreptile SummaryThis PR fixes a critical bug in the copilot permission checking logic. The issue occurs when users are not part of a permission group - in such cases, The Bug: The Fix: Files Changed:
Impact: Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client as Copilot Client
participant Tool as Server Tool (e.g., get-block-config)
participant PermCheck as getUserPermissionConfig()
participant DB as Database
Client->>Tool: Execute tool with userId & blockType
Tool->>PermCheck: getUserPermissionConfig(userId)
alt User not in organization
PermCheck->>DB: Query member table
DB-->>PermCheck: No membership found
PermCheck-->>Tool: return null
Note over Tool: permissionConfig = null<br/>allowedIntegrations = undefined
else User in org, not enterprise
PermCheck->>DB: Query organization plan
DB-->>PermCheck: Not enterprise plan
PermCheck-->>Tool: return null
Note over Tool: permissionConfig = null<br/>allowedIntegrations = undefined
else User in org, enterprise, no permission group
PermCheck->>DB: Query permission group membership
DB-->>PermCheck: No group membership
PermCheck-->>Tool: return null
Note over Tool: permissionConfig = null<br/>allowedIntegrations = undefined
else User in permission group
PermCheck->>DB: Query permission group config
DB-->>PermCheck: config object
PermCheck-->>Tool: return PermissionGroupConfig
Note over Tool: permissionConfig = {...}<br/>allowedIntegrations = null or string[]
end
alt allowedIntegrations != null (NEW FIX)
Tool->>Tool: Check if blockType in allowedIntegrations
alt blockType not in list
Tool-->>Client: throw Error (not allowed)
else blockType in list
Tool->>Tool: Continue execution
Tool-->>Client: Return result
end
else allowedIntegrations is null or undefined
Note over Tool: Skip permission check<br/>(allow all integrations)
Tool->>Tool: Continue execution
Tool-->>Client: Return result
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
Additional Comments (1)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! Prompt To Fix With AIThis is a comment left during a code review.
Path: app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/integrations/integrations.tsx
Line: 231:232
Comment:
For consistency with the permission check pattern used throughout the codebase (especially in copilot files), consider using loose equality (`!=`) instead of strict equality (`!==`). While this specific case is safe because `usePermissionConfig` always returns a config object, using `!= null` would align with the pattern established in this PR and make the codebase more consistent.
```suggestion
permissionConfig.allowedIntegrations != null &&
!permissionConfig.allowedIntegrations.includes(service.id)
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise. |
Summary
Copilot checks undefined vs null for perm config.
Type of Change
Testing
Tested manually
Checklist