Teams: teams with organization-role access show up as deletions

Open Beginner friendly
#1,144 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@TovaBecker is already working on this.

Since Nov 20, 2026.

  • #1145 by @TovaBecker — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
83/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
github, javascript
Domain
api, backend

Research direction

Read lib/plugins/teams.js and inspect Teams.find(), which calls GET /repos/{owner}/{repo}/teams. Keep direct-access teams and teams whose access_source is absent, as the issue describes. Check the existing tests for team discovery and add coverage for organization access; done when those teams no longer appear as deletions while direct teams are still handled.

Written by the indexing model from the issue text.

Description

Problem

Teams.find() in lib/plugins/teams.js lists a repository's teams with GET /repos/{owner}/{repo}/teams and doesn't filter on access_source. That endpoint also returns teams that get access from an organization role, such as all_repo_write, with access_source: "organization". Safe-settings treats these teams as repository teams, so every one that isn't in the config becomes a deletion.

In our orgs, every team has all_repo_write, so each repository lists about 120 teams. Without teams in additive_plugins, each dry run that syncs all repositories shows DELETE Team for every team on every repository: more than 15,000 changed settings in one org. That buries the real changes and makes the PR comment too large.

The real sync doesn't remove that access, because the team isn't added to the repository directly (GET /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo} returns 404). The audit log shows only removals of teams that were added directly.

Reproduce

  1. Give a team an organization role with repository access, for example all_repo_write.
  2. Use safe-settings 3.0.0 with teams not in additive_plugins, and a repository config whose teams list doesn't include that team.
  3. Open a PR that changes settings.yml. The dry-run comment shows DELETE Team for that team on every repository.

Suggested fix

In find(), keep only teams with access_source: "direct", and keep teams without access_source in case a GitHub version doesn't return the field. Safe-settings can only add or remove direct team access, so other access sources shouldn't be compared.

Dominant language
JavaScript
Stars
942
Forks
238
PR merge metrics
No merged PRs in 30d

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github-community-projects/safe-settings

All issues in github-community-projects/safe-settings

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.