Skip to content

Bug/issue-903#1010

Open
madkoo wants to merge 8 commits into
github:main-enterprisefrom
madkoo:bug/issue-903
Open

Bug/issue-903#1010
madkoo wants to merge 8 commits into
github:main-enterprisefrom
madkoo:bug/issue-903

Conversation

@madkoo

@madkoo madkoo commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

This pull request enhances the handling of GitHub organization "Security Manager" teams by updating permissions, refactoring the teams plugin to use the new organization roles API, and improving normalization and matching of team names. It also adds robust error handling and expands test coverage to ensure correct behavior when working with security manager teams.

Key changes include:

Security Manager Team Handling:

  • Refactored the teams plugin to use the new organization roles API (/orgs/{org}/organization-roles and /orgs/{org}/organization-roles/{role_id}/teams) to identify and exclude security manager teams from repository team management, replacing the deprecated security managers endpoint. The plugin now normalizes team names and slugs for accurate matching and skips deletion of security manager teams if role lookups fail gracefully.

Permissions and Documentation:

  • Added the organization_custom_roles: read permission in app.yml and updated deployment documentation to reflect the new required permission for accessing organization roles.

Team Name Normalization:

  • Improved normalization of team names and slugs throughout the teams plugin to ensure consistent matching and prevent unnecessary add/remove operations due to formatting differences.

Testing Enhancements:

  • Expanded integration and unit tests to cover security manager team exclusion, error handling for failed API calls, and normalization logic, ensuring robust and predictable plugin behavior.

These changes ensure that security manager teams are properly identified and protected from accidental removal, while keeping the codebase up to date with GitHub API changes.

Copilot AI review requested due to automatic review settings June 25, 2026 09:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the teams plugin to identify “Security Manager” teams via the GitHub Organization Roles API (instead of the deprecated security managers endpoint), improves team name/slug normalization to reduce churn, and updates required GitHub App permissions + docs, with expanded unit/integration test coverage.

Changes:

  • Refactor security-manager team detection to use /orgs/{org}/organization-roles and /orgs/{org}/organization-roles/{role_id}/teams, with graceful failure behavior.
  • Normalize team identifiers (name/slug) for matching and for getByName lookups.
  • Add required organization_custom_roles: read permission and document it; expand tests to cover the new behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/plugins/teams.js Uses org roles API to discover security-manager teams, adds normalization helpers, and introduces deletion-skipping behavior on discovery failures.
test/unit/lib/plugins/teams.test.js Adds/updates unit tests for security-manager exclusion, failure modes, and normalization behavior.
test/integration/plugins/teams.test.js Extends integration test to mock org roles API calls and ensure security-manager teams aren’t removed.
docs/deploy.md Documents the new “Custom organization roles: Read-only” permission requirement.
app.yml Adds organization_custom_roles: read to app default permissions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/plugins/teams.js
Comment on lines 42 to +46
this.log.debug(`Response from the call is ${JSON.stringify(resp)}`)
return teams.filter(team => !resp.some(sec => sec.name === team.name))
const securityManagerTeams = this.toArray(resp, 'teams')
const securityManagerTeamIdentifiers = new Set(securityManagerTeams.flatMap(team => [team.slug, team.name].map(name => this.normalizeTeamIdentifier(name))).filter(Boolean))

return teams.filter(team => !this.isSecurityManagerTeam(team, securityManagerTeamIdentifiers))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants