Repository navigation
uv, python: leave out blank index URLs before looking up hashes - #16945
Open
nikgerling wants to merge 2 commits into
Open
nikgerling wants to merge 2 commits into
nikgerling wants to merge 2 commits into
Conversation
pip_compile_index_urls passed every credential of the job through AuthedUrlBuilder.authed_url. A credential without an index-url, such as the github.com git_source credential, gives "", so the list became [nil, ""]. CompileFileUpdater#package_hashes_for passes a truthy "" to the hash helper, and hashin then requests "/pypi/<name>/json", which fails with "ValueError: unknown url type". The dependency is left out of the update. It shows only when a package's new version has fewer hashes than the old one (update_hashes_if_required), which is why only some packages fail. Fixes dependabot#12260 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
Reopened: this was closed by accident, by a closing keyword in a pull request of mine elsewhere that only linked here. The change is unchanged and still ready for review. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The regression tests call private methods via send, contrary to testing guidelines, and leave the public handoff of filtered index URLs to the pip-compile and uv updater constructors untested.
1 open issue
What changed in this PR
This PR addresses #12260 by filtering empty credential-derived index URLs before hash lookups in the Python and uv ecosystems, preventing malformed /pypi/<name>/json requests.
Changes:
- Remove empty URLs while preserving the default-index sentinel and existing
replaces-basebehavior. - Add regression examples using mixed Git and Python index credentials in both ecosystems.
| File | Description |
|---|---|
uv/spec/dependabot/uv/file_updater_spec.rb |
Adds mixed-credential regression coverage for uv. |
uv/lib/dependabot/uv/file_updater.rb |
Filters empty index URLs before uv hash lookups. |
python/spec/dependabot/python/file_updater_spec.rb |
Adds mixed-credential regression coverage for Python. |
python/lib/dependabot/python/file_updater.rb |
Applies the same empty-URL filtering to Python. |
Review effort: Balanced
| end | ||
|
|
||
| it "leaves it out, so no hash lookup gets an empty index URL" do | ||
| expect(instance.send(:pip_compile_index_urls)).to eq([nil, "https://pypi.example.com/simple"]) |
This branch has not been deployed
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.

What are you trying to accomplish?
Fixes #12260: some Python packages fail to update with
ValueError: unknown url type: '/pypi/<name>/json'when the requirements file is compiled with hashes. Theuvecosystem (uv pip compile --generate-hashes) fails the same way aspip.FileUpdater#pip_compile_index_urls(identical inuvandpython) passes every credential of the job throughAuthedUrlBuilder.authed_url. A credential without anindex-url, such as the github.comgit_sourcecredential, gives"", so the list becomes[nil, ""].CompileFileUpdater#package_hashes_forthen doesargs << index_url if index_url. Because""is truthy,hashinbuilds"" + "/pypi/<name>/json". ThatValueErroris not aPackageNotFoundError, so it is re-raised and the dependency is left out of the update.Only some packages hit this.
package_hashes_foris reached throughupdate_hashes_if_required, which runs only when a package's new version has fewer hashes than the old one. That happens when the new release, or something it pulls in, ships fewer distribution files. Examples:hypothesis6.168.5 → 6.170.15, andimport-linter2.15 → 2.16 (which pullsgrimp3.17 → 3.20).Anything you want to highlight for special attention from reviewers?
The change drops blank URLs where the list is built, in both ecosystems. The other option was to treat
""likenilinpackage_hashes_for. That would query the default index twice and add every hash twice. A credential with anindex-urlis unaffected, and so is thereplaces-basebranch.How will you know you've accomplished your goal?
uv/spec/dependabot/uv/file_updater_spec.rband inpython/spec/dependabot/python/file_updater_spec.rbuses a realgit_sourcecredential and a realpython_indexcredential. It expects[nil, "https://pypi.example.com/simple"], where the code before this change returned[nil, "", "https://pypi.example.com/simple"].pip_compile_index_urlsexamples are unchanged.Checklist
🤖 Generated with Claude Code