Skip to content

Retry logic if create-team fails #1381

Open
@dylan-smith

Description

@dylan-smith

Description

If the API call to create a team fails (e.g. 5xx error) it won't currently be retried, since we don't retry writes by default.

Here is an example of this happening in a CI build while running integration tests: https://github.com/github/gh-gei/actions/runs/16121330544/job/45487809333#step:16:215

[2025-07-07 15:39:05] [INFO] You are running an up-to-date version of the ado2gh CLI [v9.9.0]
[2025-07-07 15:39:05] [INFO] GITHUB ORG: ***-e2e-ado-basic-macos-2
[2025-07-07 15:39:05] [INFO] TEAM NAME: gei-e2e-1-Maintainers
[2025-07-07 15:39:05] [INFO] IDP GROUP: gei-e2e-1-Maintainers
[2025-07-07 15:39:05] [INFO] Creating GitHub team...
[2025-07-07 15:39:05] [DEBUG] HTTP GET: https://api.github.com/orgs/***-e2e-ado-basic-macos-2/teams
[2025-07-07 15:39:05] [DEBUG] GITHUB REQUEST ID: 8C49:74CE4:3D1C02:3EAF7D:686BEA1A
[2025-07-07 15:39:05] [DEBUG] RESPONSE (OK): [{"name":"gei-e2e-2-Admins","id":13508943,"node_id":"T_kwDOCvQb784AziFP","slug":"gei-e2e-2-admins","description":null,"privacy":"closed","notification_setting":"notifications_enabled","url":"https://api.github.com/organizations/183770095/team/13508943","html_url":"https://github.com/orgs/***-e2e-ado-basic-macos-2/teams/gei-e2e-2-admins","members_url":"[https://api.github.com/organizations/183770095/team/13508943/members{/member}](https://api.github.com/organizations/183770095/team/13508943/members%7B/member%7D)","repositories_url":"https://api.github.com/organizations/183770095/team/13508943/repos","permission":"pull","parent":null},{"name":"gei-e2e-2-Maintainers","id":13508939,"node_id":"T_kwDOCvQb784AziFL","slug":"gei-e2e-2-maintainers","description":null,"privacy":"closed","notification_setting":"notifications_enabled","url":"https://api.github.com/organizations/183770095/team/13508939","html_url":"https://github.com/orgs/***-e2e-ado-basic-macos-2/teams/gei-e2e-2-maintainers","members_url":"[https://api.github.com/organizations/183770095/team/13508939/members{/member}](https://api.github.com/organizations/183770095/team/13508939/members%7B/member%7D)","repositories_url":"https://api.github.com/organizations/183770095/team/13508939/repos","permission":"pull","parent":null}]
[2025-07-07 15:39:05] [DEBUG] HTTP POST: https://api.github.com/orgs/***-e2e-ado-basic-macos-2/teams
[2025-07-07 15:39:06] [DEBUG] HTTP BODY: {"name":"gei-e2e-1-Maintainers","privacy":"closed"}
[2025-07-07 15:39:16] [DEBUG] GITHUB REQUEST ID: 8C49:74CE4:3D2010:3EB3A4:686BEA1A
[2025-07-07 15:39:16] [DEBUG] RESPONSE (InternalServerError): 
Error: 7-07 15:39:16] [ERROR] [HTTP ERROR 500] System.Net.Http.HttpRequestException: GitHub API error: 
 ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at OctoshiftCLI.Services.GithubClient.SendAsync(HttpMethod httpMethod, String url, Object body, HttpStatusCode expectedStatus, Dictionary`2 customHeaders)
   --- End of inner exception stack trace ---
   at OctoshiftCLI.Services.GithubClient.SendAsync(HttpMethod httpMethod, String url, Object body, HttpStatusCode expectedStatus, Dictionary`2 customHeaders)
   at OctoshiftCLI.Services.GithubClient.PostAsync(String url, Object body, Dictionary`2 customHeaders)
   at OctoshiftCLI.Services.GithubApi.CreateTeam(String org, String teamName)
   at OctoshiftCLI.Commands.CreateTeam.CreateTeamCommandHandler.Handle(CreateTeamCommandArgs args)

We could improve the logic to safely retry this call by checking to see if the team exists or not, and if not retrying the API to create it. If the team exists we can return successfully.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions