Restore missing-entry guard in CoursierResolvedLockfile.dependencies() (regression from #22906)#23341
Open
enragedginger wants to merge 2 commits into
Open
Restore missing-entry guard in CoursierResolvedLockfile.dependencies() (regression from #22906)#23341enragedginger wants to merge 2 commits into
enragedginger wants to merge 2 commits into
Conversation
Contributor
|
How far back should this PR be backported? |
Contributor
|
It breaks for me in 2.31.0 2.30.0 doesn't have this problem |
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.
Disclaimer: I used Claude Code to evaluate and confirm comments from #23328. Basically, part of #22906 needs to be reverted.
Okay, now here's Claude:
Summary
Fixes a
KeyErrorregression introduced by #22906 that breakspants check(and other JVM goals) on lockfiles whose entries reference a transitive dependency that has no top-level coord entry of its own.#22906 bumped Coursier to v2.1.24 to pick up the fix for coursier#2884 and, on the assumption that the only remaining "missing entry" cases would be parent POMs (
classifier="pom"), simplifiedCoursierResolvedLockfile.dependencies()to do a direct dict lookup instead of anentries.get(...)guard. That assumption turns out to be wrong: even fresh resolves with the latest Coursier (verified against v2.1.25-M19) still emit transitive deps without a coord entry — e.g.("org.apache.curator", "apache-curator", None)when resolvingorg.apache.hive:hive-exec:1.1.0, or("org.apache.arrow", "arrow-memory", None)in the user-reported repro onhive-exec:3.1.3. Both haveclassifier=None, so theif d.classifier != "pom"filter doesn't catch them, and the unguarded lookup raisesKeyError.This restores the pre-#22906
entries.get(...)skip and adds the bug-report repro as a regression test.Changes
src/python/pants/jvm/resolve/coursier_fetch.py: restore theentries.get(...)guard independencies(); update the comment to reflect that [trigger ci] some ivy work in progress #2884-style missing entries are still observable on current Coursier.src/python/pants/jvm/resolve/coursier_fetch_test.py: addtest_dependencies_skips_transitive_entries_missing_from_lockfile— the exact fixture from the bug report. Without the fix it reproducesKeyError: ('org.apache.arrow', 'arrow-memory', None); with the fix it passes.Out of scope
CoursierResolvedLockfile.direct_dependencies()has the same unguarded pattern but predates Update Coursier default version to v2.1.24 #22906; leaving for a follow-up PR.plans/20251117_jvm_transitive_dep_bug.mdis also a follow-up.Test plan
test_dependencies_skips_transitive_entries_missing_from_lockfilepasses with the fix and fails (with the originalKeyError) without it../pants test src/python/pants/jvm/resolve/coursier_fetch_test.py src/python/pants/jvm/resolve/coursier_fetch_integration_test.py— all pass../pants fmt lint checkclean on both changed files.