Skip to content

fix(pypi): allow index probes to fail on root path#3770

Open
udaya2899 wants to merge 1 commit into
bazel-contrib:mainfrom
udaya2899:fix-issue-3769
Open

fix(pypi): allow index probes to fail on root path#3770
udaya2899 wants to merge 1 commit into
bazel-contrib:mainfrom
udaya2899:fix-issue-3769

Conversation

@udaya2899
Copy link
Copy Markdown

@udaya2899 udaya2899 commented May 11, 2026

In rules_python v2.0.0, the module extension introduced a step to fetch the list of available packages from each index to create a mapping and optimize downloads. This is implemented in python/private/pypi/simpleapi_download.bzl in _get_dist_urls. It unconditionally attempts to download the root page of every index in index_urls (with parse_index = True).

If an extra index does not support root listing (e.g., it's just a file server hosting wheels and returns 404 Not Found for the root path), the build fails with an IOException.

This change passes allow_fail = True to read_simpleapi when probing indexes, and checks result.success before accessing result.output, skipping failed indexes.

Fixes #3769

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the _get_dist_urls function in simpleapi_download.bzl to allow download failures by passing allow_fail = True and skipping unsuccessful results. A review comment correctly identifies that this change will break existing tests because the mock functions used in the test suite do not yet accept the allow_fail keyword argument, requiring an update to the mock signatures.

parse_index = True,
versions = {pkg: None for pkg in sources},
block = block,
allow_fail = True,
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.

high

Adding allow_fail = True here will cause existing tests to fail. The mock read_simpleapi functions in tests/pypi/simpleapi_download/simpleapi_download_tests.bzl (specifically in _test_simple and _test_index_overrides) do not accept the allow_fail keyword argument.

You should update those mock signatures to include **kwargs or explicitly accept allow_fail to maintain compatibility with this change.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Requesting a better solution if it exists, and if the fix is not obvious, or simple, I am happy with closing this (tbh low effort) PR. I created this because this worked for our use case.

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.

Another fix could be to just not call the index at all if there is only one index url given.

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.

[pypi] Module extension fails if an extra index returns 404 on root path, even if simpleapi_skip is set

2 participants