Skip to content

fix(bootstrapper): log specific error types in wheel cache lookup#1029

Open
LalatenduMohanty wants to merge 2 commits intopython-wheel-build:mainfrom
LalatenduMohanty:fix/differentiate-network-errors-in-wheel-cache-lookup
Open

fix(bootstrapper): log specific error types in wheel cache lookup#1029
LalatenduMohanty wants to merge 2 commits intopython-wheel-build:mainfrom
LalatenduMohanty:fix/differentiate-network-errors-in-wheel-cache-lookup

Conversation

@LalatenduMohanty
Copy link
Copy Markdown
Member

Replace bare except Exception in _download_wheel_from_cache() with three handlers so logs distinguish why a cache lookup failed:

  • ResolverException → INFO (wheel not found)
  • RequestException → WARNING (network error)
  • Exception → WARNING (unexpected error, e.g. bad wheel file, I/O)

All three still return (None, None) to preserve existing behavior.

Closes: #1025

@LalatenduMohanty LalatenduMohanty requested a review from a team as a code owner April 6, 2026 15:28
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

Warning

Rate limit exceeded

@mergify[bot] has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 44 minutes and 33 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 44 minutes and 33 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 667d1a17-cf10-4b5d-a7fa-d6eba93d3815

📥 Commits

Reviewing files that changed from the base of the PR and between e6784f8 and 7568402.

📒 Files selected for processing (2)
  • src/fromager/bootstrapper.py
  • tests/test_bootstrapper.py
📝 Walkthrough

Walkthrough

The PR replaces a broad except Exception in Bootstrapper._download_wheel_from_cache() with three specific handlers: ResolverException (logs INFO and returns (None, None)), requests.exceptions.RequestException (logs WARNING about network errors and returns (None, None)), and a final except Exception for unexpected errors (logs WARNING and returns (None, None)). It adds pytest coverage in tests/test_bootstrapper.py for resolver-not-found, various requests errors, unexpected exceptions, download-time errors, and an early-return when cache_wheel_server_url is empty.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: replacing a bare exception handler with specific error type logging in the wheel cache lookup function.
Description check ✅ Passed The description clearly explains the three exception handlers and their log levels, directly addressing the issue of distinguishing network errors from genuine cache misses.
Linked Issues check ✅ Passed The code changes fully address issue #1025: ResolverException returns INFO, RequestException and other exceptions return WARNING, and all branches preserve the (None, None) return behavior.
Out of Scope Changes check ✅ Passed All changes are directly scoped to differentiating error handling in _download_wheel_from_cache() and adding corresponding test coverage; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@mergify mergify bot added the ci label Apr 6, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/test_bootstrapper.py`:
- Around line 304-318: The test test_resolver_exception_returns_none should also
assert that ResolverException triggers the "did not find wheel" INFO log path:
when calling Bootstrapper._download_wheel_from_cache with
fromager.resolver.resolve patched to raise ResolverException, capture logs
(e.g., using caplog) and assert an INFO-level record contains the phrase "did
not find wheel" (or the exact message emitted by _download_wheel_from_cache) in
addition to asserting the return value is (None, None); update the test to
reference ResolverException and bt._download_wheel_from_cache so the log
assertion focuses on that code path.
- Around line 396-406: The test test_no_cache_url_returns_none does not assert
that the resolver is not invoked; update it to mock or spy on
fromager.resolver.resolve and assert it was not called when
Bootstrapper.cache_wheel_server_url is empty; specifically instantiate
bootstrapper.Bootstrapper, set cache_wheel_server_url = "", call
_download_wheel_from_cache with the Requirement/Version, and then assert
fromager.resolver.resolve (or the injected resolver used by Bootstrapper) had
zero invocations to validate the early-return guard.
🪄 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: c95b0344-a5aa-404c-ab53-0466adcc8d05

📥 Commits

Reviewing files that changed from the base of the PR and between 9a24ab8 and 2199620.

📒 Files selected for processing (2)
  • src/fromager/bootstrapper.py
  • tests/test_bootstrapper.py

Comment thread tests/test_bootstrapper.py Outdated
Comment thread tests/test_bootstrapper.py Outdated
@LalatenduMohanty LalatenduMohanty force-pushed the fix/differentiate-network-errors-in-wheel-cache-lookup branch 2 times, most recently from 3d0214e to fd5be04 Compare April 6, 2026 16:51
Copy link
Copy Markdown

@jlarkin09 jlarkin09 left a comment

Choose a reason for hiding this comment

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

LGTM

rd4398
rd4398 previously approved these changes Apr 7, 2026
Copy link
Copy Markdown
Contributor

@rd4398 rd4398 left a comment

Choose a reason for hiding this comment

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

This looks good to me!

Comment thread tests/test_bootstrapper.py Outdated
Comment thread tests/test_bootstrapper.py Outdated
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Apr 16, 2026

This pull request has merge conflicts that must be resolved before it can be merged.
@LalatenduMohanty please rebase your branch.

@LalatenduMohanty LalatenduMohanty force-pushed the fix/differentiate-network-errors-in-wheel-cache-lookup branch from fd5be04 to e6784f8 Compare April 16, 2026 14:25
Replace bare `except Exception` in `_download_wheel_from_cache()` with
three handlers so logs distinguish why a cache lookup failed:
- ResolverException → INFO (wheel not found)
- RequestException → WARNING (network error)
- Exception → WARNING (unexpected error, e.g. bad wheel file, I/O)

All three still return (None, None) to preserve existing behavior.

Closes: python-wheel-build#1025
Co-Authored-By: Claude <claude@anthropic.com>
Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>
@LalatenduMohanty LalatenduMohanty force-pushed the fix/differentiate-network-errors-in-wheel-cache-lookup branch from e6784f8 to 960587a Compare April 16, 2026 14:31
Copy link
Copy Markdown
Contributor

@rd4398 rd4398 left a comment

Choose a reason for hiding this comment

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

This looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Network errors during wheel cache lookup are silently swallowed in _download_wheel_from_cache()

5 participants