Teams: teams with organization-role access show up as deletions
Maintainers usually reply within 2 days
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
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
- Give a team an organization role with repository access, for example
all_repo_write. - Use safe-settings 3.0.0 with
teamsnot inadditive_plugins, and a repository config whoseteamslist doesn't include that team. - Open a PR that changes
settings.yml. The dry-run comment showsDELETE Teamfor 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
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from github-community-projects/safe-settings
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
github-community-projects/safe-settings#1143 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
github-community-projects/safe-settings#1135 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
github-community-projects/safe-settings#1134 ·
Maintainers usually reply within 2 days
-
environments: additive_plugins is ignored, undeclared environments are deletedPossibly taken @yaunj claimed this 12 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
github-community-projects/safe-settings#1133 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
github-community-projects/safe-settings#1130 ·
Maintainers usually reply within 2 days
All issues in github-community-projects/safe-settings
Similar issues
-
area:webapp bug finding
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
humlab-sead/sead_shape_shifter#779 ·
Maintainers usually reply within 1 day
-
enhancement feature/llm-analytics
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
PostHog/posthog#139959 · 1 comment ·
Maintainers usually reply within 1 day
-
ci good first issue priority:p1
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
mobeloper/better-oss#23 ·
-
accessibility Could Have good first issue seo
Difficulty 1/5 Under an hour Newbie friendliness 88/100
hannahro15/Musical-Match-Saga#278 ·
Maintainers usually reply within 1 day