-
Notifications
You must be signed in to change notification settings - Fork 0
[BB-1886] Fix role lookups for privilege grants #38
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
WalkthroughThe PR modifies role grant handling in the connector by introducing a "No access" role skip condition in collaborator grants and refactoring role metadata retrieval in the role resolver to use role traits (id, name, profile) from the resource instead of directly accessing resource properties. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
pkg/connector/role.go (1)
126-141: LGTM! Minor optimization opportunity.The role trait extraction logic is correct and provides proper error handling. Consider caching the
profile.AsMap()result to avoid calling it twice:🔎 Optional: cache AsMap() result
profile := roleTrait.GetProfile() if profile == nil { return nil, nil, fmt.Errorf("role profile not found on resource %s", resource.Id.Resource) } - roleId, ok := profile.AsMap()["id"].(string) + profileMap := profile.AsMap() + roleId, ok := profileMap["id"].(string) if !ok { return nil, nil, fmt.Errorf("role id not found on resource %s", resource.Id.Resource) } - roleName, ok := profile.AsMap()["name"].(string) + roleName, ok := profileMap["name"].(string) if !ok { return nil, nil, fmt.Errorf("role name not found on resource %s", resource.Id.Resource) }pkg/connector/collaborator.go (1)
208-209: Correctly skips "No access" role during grant construction.The placement after the base role check is appropriate since "No access" is not a base role, and skipping it prevents attempting to create grants for a role that doesn't exist as a grantable resource.
For consistency, consider defining
noAccessRoleNamein theworkatopackage alongside the base roles, which would centralize all role-related constants:#!/bin/bash # Check if there are other role name constants defined in the workato package rg -n "RoleName|role.*=" pkg/connector/workato/roles.go
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
pkg/connector/collaborator.gopkg/connector/role.go
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/connector/role.go (1)
pkg/connector/workato/roles.go (2)
IsBaseRole(18-25)GetBaseRole(27-38)
🔇 Additional comments (3)
pkg/connector/role.go (2)
144-145: Correct alignment with base role lookup functions.Using
roleNamefrom the role trait profile aligns correctly withworkato.IsBaseRole()andworkato.GetBaseRole(), which compare againstrole.RoleNameas shown in the relevant code snippets.
180-184: Good fix for role lookup by ID.The change to use
roleIdextracted from the role trait profile (instead ofresource.Id.Resource) correctly resolves the lookup issue for custom roles. The enhanced error message including both display name and roleId improves debuggability.pkg/connector/collaborator.go (1)
23-26: Good use of constant to avoid magic string.
Fixes various issues: