Skip to content

Add retry logic to create-team command for 5xx server errors #1382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 8, 2025

Problem

The create-team command would fail permanently when encountering 5xx server errors (like HTTP 500 Internal Server Error) because the CLI doesn't retry write operations by default. This was causing integration test failures and user frustration when GitHub's API experienced temporary issues.

Example error from CI:

[2025-07-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).

Solution

Modified the GithubApi.CreateTeam() method to use the existing HttpRetry mechanism with intelligent idempotency checking:

  1. Retry on 5xx errors: Uses HttpRetry with a filter for server errors (≥500)
  2. Idempotency check: Before retrying, checks if the team was actually created despite the error response
  3. Safe recovery: If team exists, returns the existing team details instead of attempting to create it again
  4. Preserves existing behavior: 4xx client errors still don't retry (correct behavior)

Changes Made

  • Modified GithubApi.CreateTeam(): Added retry logic with idempotency checking
  • Added comprehensive tests:
    • Test retry on 500 error when team gets created
    • Test retry on 502 error with successful retry
    • Test that 400 errors don't trigger retries
  • Updated release notes: Added user-friendly description of the fix

Testing

  • All existing tests continue to pass (116 GithubApi tests)
  • New tests verify retry behavior works correctly
  • Integration with existing retry policy infrastructure

The implementation ensures the create-team command is now resilient to temporary GitHub API issues while maintaining safety through idempotency checks.

Fixes #1381.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: dylan-smith <1508559+dylan-smith@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Retry logic if create-team fails Add retry logic to create-team command for 5xx server errors Jul 8, 2025
@Copilot Copilot AI requested a review from dylan-smith July 8, 2025 03:45
Copilot finished work on behalf of dylan-smith July 8, 2025 03:45
Co-authored-by: dylan-smith <1508559+dylan-smith@users.noreply.github.com>
@Copilot Copilot AI requested a review from dylan-smith July 8, 2025 04:04
Copilot finished work on behalf of dylan-smith July 8, 2025 04:05
Co-authored-by: dylan-smith <1508559+dylan-smith@users.noreply.github.com>
@Copilot Copilot AI requested a review from dylan-smith July 8, 2025 04:13
Copilot finished work on behalf of dylan-smith July 8, 2025 04:13
Co-authored-by: dylan-smith <1508559+dylan-smith@users.noreply.github.com>
Copilot finished work on behalf of dylan-smith July 8, 2025 04:18
@Copilot Copilot AI requested a review from dylan-smith July 8, 2025 04:32
Copilot finished work on behalf of dylan-smith July 8, 2025 04:32
Copy link

github-actions bot commented Jul 8, 2025

Unit Test Results

  1 files    1 suites   20s ⏱️
901 tests 901 ✅ 0 💤 0 ❌
902 runs  902 ✅ 0 💤 0 ❌

Results for commit 9524d1c.

Copy link

github-actions bot commented Jul 8, 2025

Code Coverage

Package Line Rate Branch Rate Complexity Health
Octoshift 87% 76% 1445
bbs2gh 82% 76% 669
gei 81% 73% 596
ado2gh 84% 78% 618
Summary 84% (7288 / 8626) 76% (1712 / 2262) 3328

Co-authored-by: dylan-smith <1508559+dylan-smith@users.noreply.github.com>
@Copilot Copilot AI requested a review from dylan-smith July 8, 2025 18:02
Copilot finished work on behalf of dylan-smith July 8, 2025 18:02
@dylan-smith dylan-smith marked this pull request as ready for review July 8, 2025 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retry logic if create-team fails
2 participants