Skip to content

Fix: Patch comparison for Teams plugin to match on slug instead of name on NOP - #1070

Open
StephHope wants to merge 1 commit into
github-community-projects:main-enterprisefrom
GallagherSecurity:fix-teams-slug-comparison
Open

Fix: Patch comparison for Teams plugin to match on slug instead of name on NOP#1070
StephHope wants to merge 1 commit into
github-community-projects:main-enterprisefrom
GallagherSecurity:fix-teams-slug-comparison

Conversation

@StephHope

@StephHope StephHope commented Aug 21, 2026

Copy link
Copy Markdown

Fixes #1033

Problem

In nop mode (PR comment / dry-run diffing), the Teams plugin's diff compares existing GitHub teams against the configured teams by matching on name. GitHub's team list API returns each team's display name (e.g. "Platform Engineering"), while settings.yml configures teams by slug (e.g. platform-engineering). Whenever a team's display name differs from its slug, the comparator treats the existing team and the configured team as unrelated entries, reporting a phantom addition + deletion for a team that hasn't actually changed - even though the real (non-nop) sync already matches correctly on slug.

Fix

Teams.find() now normalizes each fetched team's name to its slug (after the checkSecurityManager filter), so the nop-mode diff pairs teams the same way the real sync does.

Testing

Added test/unit/lib/plugins/teams.slug-fix.test.js, covering:

  • An unchanged team whose display name differs from its slug produces no diff output.
  • A team with a genuine permission change still reports only the real modification, with no phantom additions/deletions from the name/slug mismatch.

Copilot AI lite review requested due to automatic review settings August 21, 2026 04:39

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

Aligns the Teams plugin’s nop-mode (dry-run PR comment) diff behavior with the real sync logic by ensuring array-item identity matches on team slug rather than GitHub’s display name, eliminating phantom add/delete noise when nothing actually changes.

Changes:

  • Normalize fetched team records so name is set to slug (after checkSecurityManager) to keep MergeDeep.compareDeep() pairing consistent with slug-based sync decisions.
  • Add a regression unit test covering the slug-vs-display-name mismatch case in nop mode (both unchanged and permission-changed scenarios).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/plugins/teams.js Normalizes team name to slug post-security-manager filtering so nop diffs pair teams correctly and avoid phantom add/delete output.
test/unit/lib/plugins/teams.slug-fix.test.js Adds regression coverage ensuring nop-mode output is quiet for unchanged teams and remains focused for real permission changes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@StephHope
StephHope force-pushed the fix-teams-slug-comparison branch from df99e75 to 79cbca7 Compare August 21, 2026 04:48
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.

Teams plugin: PR comment/nop diff shows phantom additions+deletions for unchanged teams due to name vs. slug mismatch

2 participants