-
Notifications
You must be signed in to change notification settings - Fork 88
Fix http error reporting and json metadata handling #1351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hstct
wants to merge
1
commit into
pulp:main
Choose a base branch
from
ATIX-AG:fix-error-handling
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
CHANGES/+fixed-error-reporting-and-json-metadata-handling.bugfix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fixed python syncs masking HTTP errors as stale metadata and handling native json list values in package metadata |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: pulp/pulp_python
Length of output: 5206
🏁 Script executed:
Repository: pulp/pulp_python
Length of output: 5526
🌐 Web query:
bandersnatch 6.6.0 master.py Master __aexit__ session GitHub💡 Result:
In the bandersnatch codebase, specifically within the src/bandersnatch/master.py module, the Master class implements the asynchronous context manager protocol using the aenter and aexit methods [1][2]. When the Master object is used as an asynchronous context manager (e.g., using async with Master(...) as master:), the aexit method is responsible for gracefully shutting down the HTTP session [1][2]. It executes the following operations [1][2]: 1. Closes the aiohttp.ClientSession: It calls await self.session.close to terminate the active session [1][2]. 2. Adds a short delay: It awaits asyncio.sleep(0.1) to allow the session time to close properly, which helps prevent potential warnings related to connection handling issues in aiohttp [1][2]. This implementation ensures that resources associated with the Master class's network operations are cleaned up correctly after the context block exits [1][2].
Citations:
🏁 Script executed:
Repository: pulp/pulp_python
Length of output: 621
🏁 Script executed:
Repository: pulp/pulp_python
Length of output: 312
🏁 Script executed:
Repository: pulp/pulp_python
Length of output: 239
🌐 Web query:
site:github.com/pypa/bandersnatch/blob/6.6.0 bandersnatch/master.py "async def __aexit__"💡 Result:
The file is under
src/, notbandersnatch/. In Bandersnatch 6.6.0,__aexit__is at lines 94–99:Source:
src/bandersnatch/master.py(raw.githubusercontent.com)Citations:
🏁 Script executed:
Repository: pulp/pulp_python
Length of output: 629
Restore
master.sessionin afinallyblock.If
pmirror.synchronizeraises, execution skips the restoration. Bandersnatch 6.6.0Master.__aexit__then closes the assigneddownloader.session, while the originalmaster.sessionremains unclosed.🤖 Prompt for AI Agents
Source: MCP tools
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: pulp/pulp_python
Length of output: 15760
🏁 Script executed:
Repository: pulp/pulp_python
Length of output: 6959
🏁 Script executed:
Repository: pulp/pulp_python
Length of output: 50372
🌐 Web query:
bandersnatch Master all_packages changed_packages source raise_for_status get ClientResponseError💡 Result:
In Bandersnatch, the methods all_packages and changed_packages are core components of the Master class used to fetch project data from the PyPI Simple API [1][2]. These methods are designed to retrieve information about packages and their serial numbers to determine which projects need to be synchronized [3][4]. The mention of raise_for_status and ClientResponseError relates to Bandersnatch's use of the aiohttp library for HTTP requests [5][6]. Bandersnatch implements raise_for_status on its aiohttp responses to ensure that any HTTP status code of 400 or higher triggers a ClientResponseError [7][6]. This defensive programming practice allows the application to explicitly catch and handle failed network requests—such as when a PyPI endpoint returns an error—rather than proceeding with invalid or empty data [7][6]. In practice, when Bandersnatch performs network operations, it uses aiohttp to manage connections [3][6]. By calling raise_for_status on these requests, the application enforces error handling where receiving an unsuccessful HTTP status (e.g., 404 Not Found or 500 Internal Server Error) raises a ClientResponseError, which is part of the aiohttp.client_exceptions module [5][7][6]. This ensures that synchronization failures are captured and can be managed according to the user's mirror configuration (e.g., whether to stop on error or continue) [8][6].
Citations:
🏁 Script executed:
Repository: pulp/pulp_python
Length of output: 3663
🏁 Script executed:
Repository: pulp/pulp_python
Length of output: 6312
🏁 Script executed:
Repository: pulp/pulp_python
Length of output: 3483
🌐 Web query:
aiohttp-xmlrpc ServerProxy client aiohttp ClientSession raise_for_status ClientResponseError💡 Result:
When using aiohttp-xmlrpc, the ServerProxy client internally utilizes aiohttp's ClientSession to perform HTTP POST requests [1]. Inside the implementation of the remote call mechanism, the library calls response.raise_for_status on the aiohttp ClientResponse object after the request is executed [1]. If the XML-RPC server returns an HTTP error status code (e.g., 4xx or 5xx), aiohttp's raise_for_status method will raise a ClientResponseError [2][3]. This is expected behavior in aiohttp, as raise_for_status is designed to automatically throw an exception for unsuccessful HTTP responses [4]. Regarding potential issues with this process: 1. Handling the Exception: If you are using aiohttp-xmlrpc and encounter a ClientResponseError, it indicates that the underlying HTTP layer received an error status from the server, rather than a successful 200 OK response [2][3]. You should implement error handling (try/except blocks) around your ServerProxy method calls to catch ClientResponseError and handle the server failure appropriately. 2. Historical Context: There was a known issue in older versions of aiohttp where raise_for_status could raise an AssertionError if the response reason was empty [5]. This has generally been addressed in modern versions of the library, so ensure you are using an up-to-date version of aiohttp if you experience unexpected AssertionErrors. 3. Troubleshooting: If the error persists, check your XML-RPC server logs to see why it is returning an HTTP error status instead of a standard XML-RPC response [1]. If you find that the default behavior of raise_for_status does not suit your needs, note that the library's design tightly couples these calls to the internal aiohttp response handling [1]. You may need to wrap your calls specifically to catch and process these HTTP-level errors before they propagate as ClientResponseError exceptions.
Citations:
Do not swallow HTTP status errors in the XML-RPC fallback.
aiohttp-xmlrpcraisesClientResponseErrorfor 404 and 5xx responses.PulpMirror.determine_packages_to_synccatches it throughClientError, retries three times, and then reads/simple/instead of failing the sync. Re-raiseClientResponseError, and keep the fallback only for the XML-RPC-unavailable condition. Add regression tests for 404 and 5xx responses.🤖 Prompt for AI Agents
Source: MCP tools