Conversation
Fix TypeScript compilation error in CI by supporting both Organization object and string orgId in OrganizationService.deleteTeamMember. Co-authored-by: Cursor <cursoragent@cursor.com>
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_799da80d-6af1-49a2-a253-0978fa7ff666) |
There was a problem hiding this comment.
Code Review
This pull request updates the deleteTeamMember method in OrganizationService to accept either an Organization object or a string representing the organization ID, while also adding optional chaining to user role checks. The review highlights a significant security risk with this change, as overloading the method to accept a string allows authorization and role checks to be bypassed. It is recommended to keep deleteTeamMember strictly typed to Organization and introduce a separate, explicitly named method for system-level deletions.
| async deleteTeamMember(org: Organization | string, userId: string) { | ||
| if (typeof org === 'string') { | ||
| return this._organizationRepository.deleteTeamMember(org, userId); | ||
| } |
There was a problem hiding this comment.
Overloading deleteTeamMember to accept either an Organization object or a string orgId introduces a significant security risk (authorization bypass). When a string is passed, all permission and role checks are silently bypassed. If a developer in a user-facing controller accidentally passes a string orgId instead of the full Organization object, any user could delete team members without authorization.
To prevent this, keep deleteTeamMember strictly typed to Organization to enforce permission checks, and expose a separate, explicitly named method (e.g., deleteTeamMemberByOrgId) for system/webhook actions that are allowed to bypass these checks.
| async deleteTeamMember(org: Organization | string, userId: string) { | |
| if (typeof org === 'string') { | |
| return this._organizationRepository.deleteTeamMember(org, userId); | |
| } | |
| async deleteTeamMemberByOrgId(orgId: string, userId: string) { | |
| return this._organizationRepository.deleteTeamMember(orgId, userId); | |
| } | |
| async deleteTeamMember(org: Organization, userId: string) { |
What kind of change does this PR introduce?
Bug fix & CI/CD stability
Why was this change needed?
Fixes a TypeScript type mismatch error in
OrganizationService.deleteTeamMemberwhereDosOrgSyncWebhookControllerpassed a stringorgIdwhile the method originally strictly expected anOrganizationobject.Other information:
BuildandBuild & Publish Crove Containersworkflows.Checklist:
Note
Medium Risk
The new string overload skips in-service role checks for webhook-driven removals; callers must be trusted, while the user-facing delete path is unchanged.
Overview
OrganizationService.deleteTeamMembernow accepts either anOrganizationor an org id string, fixing the TypeScript mismatch whenDosOrgSyncWebhookControllerremoves members withtargetOrg.id.When the first argument is a string, the service delegates straight to the repository (no membership/role-level checks). The existing settings flow still passes a full
Organizationand keeps the same permission checks, with optional chaining onusers?.[0]?.roleso role reads don鈥檛 blow up ifusersis missing.Reviewed by Cursor Bugbot for commit 241f7cb. Bugbot is set up for automated code reviews on this repo. Configure here.