Skip to content

Add retries for brew API failures#48306

Open
allenhouchins wants to merge 3 commits into
mainfrom
allenhouchins-update-ingester
Open

Add retries for brew API failures#48306
allenhouchins wants to merge 3 commits into
mainfrom
allenhouchins-update-ingester

Conversation

@allenhouchins

@allenhouchins allenhouchins commented Jun 25, 2026

Copy link
Copy Markdown
Member

The Homebrew formulae API (served by GitHub Pages) intermittently returns 5xx errors, which previously aborted the entire ingestion run. This change adds smart retry logic with exponential backoff for transient failures (network errors, 5xx/429 responses) while preserving immediate failure for permanent errors (404, other 4xx).

Implementation:

  • Created transientErr wrapper type to distinguish retryable from permanent failures
  • Wrapped fetchCask HTTP logic in retry.Do with configurable interval and max attempts
  • Added comprehensive tests verifying recovery after transient errors, exhaustion of attempts, and non-retrying of 404s

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when fetching Homebrew casks by automatically retrying temporary failures.
    • Added smarter handling for rate limits and server/network errors, while avoiding retries for missing apps.
    • Made error messages from failed responses more concise and readable.
  • Tests
    • Added coverage to verify transient retry behavior, retry exhaustion handling, and that “not found” responses are not retried.

The Homebrew formulae API (served by GitHub Pages) intermittently returns 5xx errors, which previously aborted the entire ingestion run. This change adds smart retry logic with exponential backoff for transient failures (network errors, 5xx/429 responses) while preserving immediate failure for permanent errors (404, other 4xx).

Implementation:
- Created transientErr wrapper type to distinguish retryable from permanent failures
- Wrapped fetchCask HTTP logic in retry.Do with configurable interval and max attempts
- Added comprehensive tests verifying recovery after transient errors, exhaustion of attempts, and non-retrying of 404s
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.94340% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.43%. Comparing base (7b833d4) to head (931847c).
⚠️ Report is 23 commits behind head on main.

Files with missing lines Patch % Lines
ee/maintained-apps/ingesters/homebrew/ingester.go 50.94% 20 Missing and 6 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #48306    +/-   ##
========================================
  Coverage   67.42%   67.43%            
========================================
  Files        3665     3667     +2     
  Lines      231967   232579   +612     
  Branches    12304    12292    -12     
========================================
+ Hits       156405   156840   +435     
- Misses      61527    61637   +110     
- Partials    14035    14102    +67     
Flag Coverage Δ
backend 69.02% <50.94%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@allenhouchins allenhouchins marked this pull request as ready for review June 26, 2026 20:57
@allenhouchins allenhouchins requested a review from a team as a code owner June 26, 2026 20:57
Copilot AI review requested due to automatic review settings June 26, 2026 20:57
fleet-release
fleet-release previously approved these changes Jun 26, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 improves the reliability of the Homebrew maintained-apps ingester by adding retry logic around Homebrew formulae API fetches, so intermittent GitHub Pages 5xx/429 failures don’t abort an entire ingestion run.

Changes:

  • Added configurable retry/backoff behavior to brewIngester.fetchCask for transient HTTP/network failures.
  • Introduced a transientErr wrapper + retry error filter to distinguish retryable vs permanent failures (e.g., 404).
  • Added tests covering transient recovery, attempt exhaustion, and non-retrying of 404s.

Reviewed changes

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

File Description
ee/maintained-apps/ingesters/homebrew/ingester.go Adds retry/backoff with transient vs permanent error classification for Homebrew API fetches.
ee/maintained-apps/ingesters/homebrew/ingester_test.go Adds unit tests validating retry behavior for transient and permanent failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ee/maintained-apps/ingesters/homebrew/ingester.go
Comment thread ee/maintained-apps/ingesters/homebrew/ingester.go
@allenhouchins allenhouchins marked this pull request as draft June 26, 2026 21:00
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c44c09d9-896a-4d90-9cd7-e9dfa2f8e818

📥 Commits

Reviewing files that changed from the base of the PR and between 575d02c and 931847c.

📒 Files selected for processing (1)
  • ee/maintained-apps/ingesters/homebrew/ingester.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • ee/maintained-apps/ingesters/homebrew/ingester.go

Walkthrough

The Homebrew ingester now retries cask metadata requests with configurable interval and attempt limits. It treats 404 as a permanent missing-app error, retries selected transient failures, truncates error response bodies, and adds tests for transient recovery, retry exhaustion, and no-retry 404 handling.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning It covers the change and tests, but omits the required Related issue field and most template checklist sections. Add the repository template sections, especially Related issue and the required checklist items, and fill in any applicable QA/testing details.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding retries for brew API failures.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch allenhouchins-update-ingester

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ee/maintained-apps/ingesters/homebrew/ingester.go`:
- Around line 282-294: In the homebrew ingester retry path, transport/read
failures are always wrapped as transientErr even when the caller’s context has
already been canceled, which can cause needless retry/backoff loops. Update the
retry handling in i.client.Do and io.ReadAll error paths (and the similar block
around the later apply site) to check ctx.Err() before returning transientErr,
and if the context is done, return the context-cancellation error directly so
the retry filter stops immediately. Keep the transient retry behavior only for
genuine network/read interruptions while the context is still active.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 90ee5309-5426-45b5-a90f-0598468ece7d

📥 Commits

Reviewing files that changed from the base of the PR and between 7b833d4 and 575d02c.

📒 Files selected for processing (2)
  • ee/maintained-apps/ingesters/homebrew/ingester.go
  • ee/maintained-apps/ingesters/homebrew/ingester_test.go

Comment thread ee/maintained-apps/ingesters/homebrew/ingester.go
@allenhouchins allenhouchins marked this pull request as ready for review June 26, 2026 21:04
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.

3 participants