Repository navigation
get_package_data: keep the index URL's path - #255
Open
koenvincent wants to merge 1 commit into
Open
koenvincent wants to merge 1 commit into
koenvincent wants to merge 1 commit into
Conversation
urljoin(index_url, "/pypi/%s/json") replaces the whole path of index_url. That is harmless for https://pypi.org/, but an index served under a path, such as an Artifactory or Nexus PyPI proxy at https://host/artifactory/api/pypi/<repo>/, loses it and the request 404s. Join a relative path onto the index URL with a trailing slash instead.
hartwork
requested changes
Nov 17, 2026
hartwork
left a comment
Collaborator
There was a problem hiding this comment.
@koenvincent I am happy to help but checking for a trailing slash seems like black magic and prone to error to me. Can you please come up with an alternative that is robust and self-explaining?
5 tasks done
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
urljoin(index_url, "/pypi/%s/json")replaces the whole path ofindex_url. That is harmless forhttps://pypi.org/, but it breaks any index served under a path, such as an Artifactory or Nexus PyPI proxy athttps://host/artifactory/api/pypi/<repo>/. The request then goes tohttps://host/pypi/<pkg>/jsonand returns 404, whilehttps://host/artifactory/api/pypi/<repo>/pypi/<pkg>/jsonanswers with the JSON and sha256 digests.https://pypi.org/andhttps://pypi.orgboth still givehttps://pypi.org/pypi/<pkg>/json.This is what breaks Dependabot's hash lookup for a private Python registry under a path: its helper passes the registry URL to
hashin.get_package_hashes.Tested:
pytest tests(73 passed) with a new parametrizedtest_get_package_data_keeps_the_index_pathcovering both pypi.org forms and a path-prefixed index with and without a trailing slash;black --checkandflake8clean.