fix: use team slug instead of DisplayName for membership checks - #41
fix: use team slug instead of DisplayName for membership checks#41c1-dev-bot[bot] wants to merge 1 commit into
Conversation
The team Grant/Revoke code incorrectly compared entitlement.Resource.DisplayName against member.Teams from the Sentry API. The member.Teams field contains team slugs, not display names, so the comparison would fail whenever a team's display name differs from its slug (e.g., "My Team" vs "my-team"). Added a GetTeam client method that retrieves a team by ID and uses the returned Slug field for the membership comparison. Fixes: CXH-1371
|
Claude finished @c1-dev-bot[bot]'s task in 1m 41s —— View job PR Review: fix: use team slug instead of DisplayName for membership checks
SummaryThis is a clean, well-targeted bug fix. The core issue — comparing Verdict: Approve with minor suggestionsThe approach is sound. The code is consistent with existing patterns in the codebase and correctly addresses the slug/name mismatch. Detailed ReviewBug fix correctness ✓ The New Follows the same pattern as other client methods ( Trade-off: extra API call per Grant/Revoke Both Minor Issues
What looks good
|
| if name == teamName { | ||
| for _, slug := range member.Teams { | ||
| if slug == team.Slug { | ||
| return annotations.New(&v2.GrantAlreadyExists{}), nil |
There was a problem hiding this comment.
Nit (pre-existing, not introduced by this PR): This annotations.New(...) discards the rate-limit annotations accumulated in ann from the GetTeam and GetOrganizationMember calls above. Consider returning ann with the annotation appended instead:
| return annotations.New(&v2.GrantAlreadyExists{}), nil | |
| ann.Append(&v2.GrantAlreadyExists{}) | |
| return ann, nil |
(Check if ann.Append exists in the SDK — if not, this is fine to leave as-is since it's pre-existing behavior.)
Summary
entitlement.Resource.DisplayNameagainstmember.Teamsfrom the Sentry API. Themember.Teamsfield contains team slugs (e.g.,my-team), not display names (e.g.,My Team), so the idempotency check would fail whenever a team's display name differs from its slug.GetTeamclient method to retrieve team details by org/team ID, using the Retrieve a Team endpoint.Grant()andRevoke()now fetch the team's slug viaGetTeamand compare it againstmember.Teamsfor correct membership detection.Changes
pkg/client/urls.go— AddedTeamUrlconstant for the retrieve-a-team endpointpkg/client/teams.go— AddedGetTeam()methodpkg/connector/teams.go— UpdatedGrant()andRevoke()to useteam.Sluginstead ofentitlement.Resource.DisplayNameFixes: CXH-1371
Test plan
Automated PR Notice
This PR was automatically created by c1-dev-bot as a potential implementation.
This code requires: