Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 2, 2025

This PR implements secondary rate limit handling in the GitHub CLI to gracefully handle 403/429 responses with proper retry logic, exponential backoff, and clear error messaging, improving reliability when running multiple concurrent migrations.

Background

Recent GraphQL database rate limiting changes now count Octoshift backend operations against the PAT, causing failures when migrations run in parallel. Previously, the CLI would fail immediately on secondary rate limit errors (HTTP 403/429) without any retry logic, making it brittle in both CI and customer environments.

Key Changes

The implementation makes minimal surgical changes to the GithubClient.SendAsync method:

  1. Added IsSecondaryRateLimit method to detect secondary rate limit responses
  2. Added HandleSecondaryRateLimit method to implement retry logic with proper header handling
  3. Enhanced SendAsync method with retry count parameter and secondary rate limit handling
  4. Added comprehensive test coverage for various secondary rate limit scenarios

Closes #1425
Closes https://github.ghe.com/github/octoshift/issues/11153

@Copilot Copilot AI changed the title [WIP] Handle Secondary Rate Limit Errors in CLI Handle Secondary Rate Limit Errors in CLI Sep 2, 2025
Copilot finished work on behalf of begonaguereca September 2, 2025 20:32
@Copilot Copilot AI requested a review from begonaguereca September 2, 2025 20:32
Copy link

github-actions bot commented Sep 2, 2025

Unit Test Results

  1 files    1 suites   10m 25s ⏱️
905 tests 905 ✅ 0 💤 0 ❌
906 runs  906 ✅ 0 💤 0 ❌

Results for commit 514da55.

♻️ This comment has been updated with latest results.

@begonaguereca begonaguereca marked this pull request as ready for review September 2, 2025 22:22
@Copilot Copilot AI review requested due to automatic review settings September 2, 2025 22:22
Copy link
Contributor

@Copilot 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 implements secondary rate limit handling in the GitHub CLI to improve reliability when running concurrent migrations by adding retry logic with exponential backoff for 403/429 HTTP responses.

  • Adds detection and handling for secondary rate limits (HTTP 403/429) with automatic retry logic
  • Implements exponential backoff strategy when retry headers are not present
  • Provides clear warning messages and error handling after maximum retries are reached

Reviewed Changes

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

File Description
src/Octoshift/Services/GithubClient.cs Core implementation of secondary rate limit detection and retry logic with exponential backoff
src/OctoshiftCLI.Tests/Octoshift/Services/GithubClientTests.cs Comprehensive test coverage for various secondary rate limit scenarios including 429/403 responses and retry behavior
RELEASENOTES.md User-facing documentation of the new secondary rate limit handling feature

@V1j2t3
Copy link

V1j2t3 commented Sep 3, 2025

This PR implements secondary rate limit handling in the GitHub CLI to gracefully handle 403/429 responses with proper retry logic, exponential backoff, and clear error messaging, improving reliability when running multiple concurrent migrations.

Background

Recent GraphQL database rate limiting changes now count Octoshift backend operations against the PAT, causing failures when migrations run in parallel. Previously, the CLI would fail immediately on secondary rate limit errors (HTTP 403/429) without any retry logic, making it brittle in both CI and customer environments.

Key Changes

The implementation makes minimal surgical changes to the GithubClient.SendAsync method:

  1. Added IsSecondaryRateLimit method to detect secondary rate limit responses
  2. Added HandleSecondaryRateLimit method to implement retry logic with proper header handling
  3. Enhanced SendAsync method with retry count parameter and secondary rate limit handling
  4. Added comprehensive test coverage for various secondary rate limit scenarios

Closes #1425 Closes https://github.ghe.com/github/octoshift/issues/11153

Copy link

github-actions bot commented Sep 3, 2025

Code Coverage

Package Line Rate Branch Rate Complexity Health
gei 80% 72% 574
bbs2gh 83% 77% 653
ado2gh 83% 77% 613
Octoshift 87% 77% 1503
Summary 85% (7315 / 8631) 76% (1733 / 2276) 3343

@begonaguereca begonaguereca merged commit 7be32da into main Sep 3, 2025
66 of 77 checks passed
@begonaguereca begonaguereca deleted the copilot/fix-1425 branch September 3, 2025 19:20
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.

Handle Secondary Rate Limit Errors in CLI
4 participants