Skip to content

Wrap GitHub API calls in a retrying client with exponential backoff#144

Merged
ribtoks merged 3 commits into
masterfrom
copilot/wrap-github-api-interaction
Apr 2, 2026
Merged

Wrap GitHub API calls in a retrying client with exponential backoff#144
ribtoks merged 3 commits into
masterfrom
copilot/wrap-github-api-interaction

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

GitHub API interactions were executed directly from the service layer, so transient failures could cause issue sync operations to fail immediately. This change introduces a thin wrapper around the existing go-github client that preserves current call shapes while applying retry/backoff to retryable failures.

  • Retrying GitHub API wrapper

    • Added a dedicated githubAPI client that mirrors the GitHub operations used by the action.
    • Encapsulated retry behavior in a shared loop, with per-operation doXYZ methods invoked inside the retry path.
  • Backoff and retry policy

    • Uses github.com/jpillora/backoff for exponential backoff with jitter.
    • Retries transient GitHub failures only: rate limiting, secondary rate limiting, accepted/pending responses, HTTP 429, HTTP 5xx, and timeout-based network errors.
    • Preserves context cancellation while waiting between attempts.
  • Service wiring

    • Replaced direct *github.Client usage in the service with the retrying wrapper.
    • Routed existing issue-listing, issue-create/edit, comment-create, and commit-fetch operations through the wrapper without changing higher-level flow.
  • Targeted coverage

    • Added focused tests for retry-on-transient-error, stop-on-non-retryable-error, and context-cancel behavior.
    • Added retryability classification coverage for the GitHub and network error cases handled by the wrapper.
err := g.retry(ctx, "issues.create", func() error {
	var err error
	created, resp, err = g.doCreateIssue(ctx, owner, repo, issue)
	return err
})

Copilot AI and others added 3 commits April 2, 2026 11:26
@ribtoks ribtoks marked this pull request as ready for review April 2, 2026 12:12
@ribtoks ribtoks merged commit fb5fa9c into master Apr 2, 2026
2 checks passed
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.

2 participants