Skip to content

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

Open
LalatenduMohanty wants to merge 1 commit 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 1 commit 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

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: ff8dc0fc-2b7f-49ca-a5b5-8cb09cb4ffe0

📥 Commits

Reviewing files that changed from the base of the PR and between 3d0214e and fd5be04.

📒 Files selected for processing (2)
  • src/fromager/bootstrapper.py
  • tests/test_bootstrapper.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/fromager/bootstrapper.py
  • tests/test_bootstrapper.py

📝 Walkthrough

Walkthrough

The PR narrows a broad except Exception in Bootstrapper._download_wheel_from_cache() into 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)). Tests in tests/test_bootstrapper.py were added to cover 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 handlers to improve logging in the wheel cache lookup function.
Description check ✅ Passed The description clearly explains the changes: three distinct exception handlers for different error types with their respective log levels, while preserving existing return behavior.
Linked Issues check ✅ Passed The PR directly addresses issue #1025 by implementing three specific exception handlers to distinguish between ResolverException (INFO), RequestException (WARNING), and other exceptions (WARNING) in wheel cache lookup.
Out of Scope Changes check ✅ Passed All changes are scoped to the requirements: exception handler improvements in bootstrapper.py and comprehensive test coverage for the three failure paths specified in issue #1025.

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


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

@LalatenduMohanty LalatenduMohanty force-pushed the fix/differentiate-network-errors-in-wheel-cache-lookup branch from 2199620 to 3d0214e Compare April 6, 2026 16:36
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 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

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!

tmp_context: WorkContext,
) -> bootstrapper.Bootstrapper:
bt = bootstrapper.Bootstrapper(tmp_context)
bt.cache_wheel_server_url = "https://cache.example.com/simple"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

example.com is a real domain. Tests should use a RFC 6761 domain

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()

4 participants