Skip to content

Conversation

@brianaj
Copy link
Collaborator

@brianaj brianaj commented Dec 12, 2025

This PR merges external PR #1478 from @AakashSuresh2003 which fixes issue #1447.

Summary

Modified GetNonSuccessAsync to only retry on transient 5xx server errors, eliminating unnecessary retries on deterministic responses (200/404/301/4xx) during repository existence checks.

Problem

Previously, GetNonSuccessAsync used GetWithRetry which retried on all non-success responses, causing unnecessary delays during migrations when checking repository existence.

Solution

Changed to use HttpRetry with a custom predicate that only retries on 5xx errors:

ex => ex.StatusCode.HasValue && (int)ex.StatusCode.Value >= 500

Impact

  • DoesRepoExist(): Expects 404 → now returns immediately instead of retrying
  • GetArchiveMigrationUrl(): Expects 302 → now returns immediately instead of retrying
  • Both still retry on transient 5xx server errors

Testing

  • All 1023 tests passing
  • 5 new comprehensive test cases covering:
    • Expected status (404) returns immediately
    • Unexpected success (200) throws immediately
    • Server errors (5xx) retry as expected
    • Client errors (4xx) throw immediately
    • Redirects (301) throw immediately

Closes #1447
Merges #1478

cc: @AakashSuresh2003

@brianaj brianaj marked this pull request as ready for review December 12, 2025 21:22
Copilot AI review requested due to automatic review settings December 12, 2025 21:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue where repository existence checks were unnecessarily retrying on deterministic HTTP responses (200/404/301/4xx), causing performance delays during migrations. The solution changes GetNonSuccessAsync to use HttpRetry with a custom predicate that only retries on transient 5xx server errors.

Key Changes:

  • Modified GetNonSuccessAsync to selectively retry only on 5xx errors using HttpRetry with a custom predicate
  • Added 5 comprehensive test cases to verify retry behavior for different HTTP status codes
  • Updated release notes with user-friendly description of the fix

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Octoshift/Services/GithubClient.cs Changed GetNonSuccessAsync from using GetWithRetry to HttpRetry with a predicate that only retries on 5xx server errors
src/OctoshiftCLI.Tests/Octoshift/Services/GithubClientTests.cs Replaced single retry test with 5 comprehensive tests covering expected status, unexpected success, server errors, client errors, and redirects
RELEASENOTES.md Added user-friendly release note describing the fix for repository existence check retries

After thoroughly reviewing this PR, I found no issues. The implementation is solid and follows existing patterns in the codebase. The test coverage is comprehensive, and all changes align with the repository's coding standards. Great work on this fix! 🎉

@brianaj brianaj requested a review from a team December 12, 2025 22:05
@brianaj brianaj marked this pull request as draft December 12, 2025 22:13
@github-actions
Copy link

Unit Test Results

    1 files      1 suites   10m 25s ⏱️
1 022 tests 1 022 ✅ 0 💤 0 ❌
1 023 runs  1 023 ✅ 0 💤 0 ❌

Results for commit 2942ea9.

@github-actions
Copy link

Code Coverage

Package Line Rate Branch Rate Complexity Health
ado2gh 72% 71% 726
Octoshift 83% 73% 1769
bbs2gh 83% 78% 663
gei 81% 73% 608
Summary 81% (7861 / 9740) 74% (1909 / 2595) 3766

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.

migrate-repo command retries 5 times if target repository exists

3 participants