Skip to content

Commit 67c0712

Browse files
committed
fix: preserve excluded_members state when GitHub API doesn't return them
- Add workaround in resourceGithubTeamSettingsRead to preserve excluded_members from current state - GitHub's GraphQL API currently doesn't support reading back excluded team member IDs - This prevents Terraform from showing unwanted changes during refresh operations - Fixes test failure where excluded_members appeared as additions in plan after apply
1 parent 9832b12 commit 67c0712

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

github/resource_github_team_settings.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,19 @@ func resourceGithubTeamSettingsRead(d *schema.ResourceData, meta any) error {
197197
reviewRequestDelegation["algorithm"] = query.Organization.Team.ReviewRequestDelegationAlgorithm
198198
reviewRequestDelegation["member_count"] = query.Organization.Team.ReviewRequestDelegationCount
199199
reviewRequestDelegation["notify"] = query.Organization.Team.ReviewRequestDelegationNotifyAll
200+
201+
// NOTE: The exclusion list is not available via the GraphQL read query yet.
202+
// The excluded_team_member_node_ids field can be set but cannot be read back from the GitHub API.
203+
// This is because the GraphQL API for team review assignments is currently in preview.
204+
// As a workaround, we preserve the excluded_members from the current state.
205+
if currentDelegation := d.Get("review_request_delegation").([]any); len(currentDelegation) > 0 {
206+
if currentSettings, ok := currentDelegation[0].(map[string]any); ok {
207+
if excludedMembers, exists := currentSettings["excluded_members"]; exists {
208+
reviewRequestDelegation["excluded_members"] = excludedMembers
209+
}
210+
}
211+
}
212+
200213
if err = d.Set("review_request_delegation", []any{reviewRequestDelegation}); err != nil {
201214
return err
202215
}
@@ -205,9 +218,8 @@ func resourceGithubTeamSettingsRead(d *schema.ResourceData, meta any) error {
205218
return err
206219
}
207220
}
208-
// NOTE: The exclusion list is not available via the GraphQL read query yet.
209-
// The excluded_team_member_node_ids field can be set but cannot be read back from the GitHub API.
210-
// This is because the GraphQL API for team review assignments is currently in preview.
221+
// NOTE: The excluded members are preserved from the current state in the read logic above
222+
// since the GitHub API doesn't currently support reading them back.
211223

212224
return nil
213225
}

0 commit comments

Comments
 (0)