Repository navigation
Description
Summary
PR #3461 (#3461) switched the github_team_members Read function from a GraphQL query to the REST ListTeamMembers endpoint. Those two are not equivalent for organizations that use nested (parent/child) teams, and I think this introduces a perpetual diff for those orgs.
Details
The old Read used GraphQL:
members(membership: IMMEDIATE, first: 100, after: $after)IMMEDIATE returns only the team's direct members.
The new Read uses the REST endpoint GET /orgs/{org}/teams/{team_slug}/members (via ListTeamMembersBySlugIter / ListTeamMembersByIDIter). That endpoint always includes the members of child teams. This is documented ("Team members will include the members of child teams", see the List team members REST docs) and is confirmed in the server implementation, which builds the member scope with a hard-coded membership: "all" (the valid values are immediate, child_team, and all). The REST endpoint exposes only a role filter, so there is no way to restrict it to immediate members.
Impact
For an org with nested teams, github_team_members.members will now read back members inherited from child teams that the user never put in their configuration. Since github_team_members manages the member set authoritatively, I'd expect:
- a perpetual diff after apply, and
- potentially an update attempting to remove inherited members it does not actually manage.
Flat team structures (no child teams) are unaffected, which is probably why this passed review and acceptance tests.
Suggested direction
Restore immediate-members-only semantics. Options I can think of:
- Filter the REST results down to immediate members (e.g. cross-reference each member's direct membership), or
- Move the Read back to the GraphQL
membership: IMMEDIATEquery, or - Some hybrid that keeps the clean 404-handling from fix: skip github_team_members deletion when parent team is already gone #3461 while preserving the immediate-only member list.
Notes
The 404 handling added in #3461 (treating a 404 on member removal as "team already gone", and removing the resource from state on a 404 during Read) looks correct and worth keeping. This issue is specifically about the child-team member inclusion change in the Read path.
Activity
github-actions commentedon Jun 18, 2026
👋 Hi, and thank you for opening this issue!
This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can.
You can help us prioritize by adding details, reproduction steps, or a 👍 to issues that matter to you, and by joining the discussion on open issues and PRs.
🤖 This is an automated message.
[-]github_team_members: Read includes child-team members (REST regression vs prior GraphQL IMMEDIATE)[/-][+]github_team_members: Read includes child-team members[/+]stevehipwell commentedon Jun 19, 2026
Good spot @robert-crandall. This is one of the APIs (most of which are team APIs) that aren't consistent or fit for purpose, as it currently stands there isn't any way to get team direct members with the REST API as even using a subtraction pattern and burning API requests you still can't detect a user in the teams and a child team.