Repository navigation
Fix and correctly scope the Poetry package updater - #896
Merged
Merged
Conversation
handlePoetry ran 'poetry add <pkg>==<ver>', which rewrites whatever
constraint form was declared (range, table-with-extras, group) into
an exact pin, then a bare 'poetry update', which is unscoped (drifts
unrelated transitives) and, without --lock, installs into the
environment. It also ran in the process working directory rather than
the project the finding's evidence points at.
Replaced with the verified sequence: pin the dependency to the exact
fix version wherever its existing declaration actually is (bare
string, table-with-extras, group table, or PEP 621 native array
entry) - never via 'poetry add', which duplicates the dependency into
the main table when it actually lives in a group (verified: reproduces
this with a [tool.poetry.group.dev.dependencies] entry). Then a scoped
'poetry update <pkg> --lock --no-interaction', restore the manifest
verbatim, and re-sync the lock's content-hash without re-resolving
('poetry lock' on 2.x, 'poetry lock --no-update' on 1.x - the flag's
meaning inverted as Poetry 2.0's new default). If the original
constraint doesn't admit the fix version, restoring it verbatim
silently reverts the lock while 'poetry check --lock' still exits 0
(verified with jinja2 "^2.11" and a fix of 3.1.6) - widen by
re-applying the exact pin instead, and assert the locked version
directly rather than trusting that exit code.
Runs via cmd.Dir resolved from the finding's evidence, never the
process cwd, matching the existing Yarn/Go/Npm updaters' convention.
Never sets cmd.Env, so private-index credentials are inherited from
whatever environment the customer's own CI already provides.
Added regression tests for all three verified scenarios (byte-identical
preservation, widening, and group-table targeting without duplication)
with dedicated testdata fixtures, plus updated the existing poetry test
case to supply evidence now that the fix no longer relies on cwd.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Cut the handlePoetry doc comment from 24 lines to 3, keeping only why 'poetry add' and a bare 'poetry update' are avoided and pointing to fixPoetryDependency for the actual sequence. Removed the 5 test-function doc comments added in this branch - the file's existing convention (TestPipPackageRegex) has none. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
gosec flagged G703 (CWE-22, path traversal via taint analysis) on the four os.WriteFile calls in fixPoetryDependency that write to descriptorPath, since it's a parameter ultimately derived from scan evidence rather than a compile-time constant. G703 isn't in the workflow's exclude list, so it needs an inline suppression per call, same as the existing pattern already used for handlePip and handleUv's equivalent writes. Verified clean with gosec run locally using the exact CI flags, both scoped to packageupdaters and across the full repo (Issues: 0 in both). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Jordanh1996
reviewed
Sep 23, 2026
Jordanh1996
reviewed
Sep 23, 2026
Jordanh1996
reviewed
Sep 23, 2026
Jordanh1996
reviewed
Sep 23, 2026
Jordanh1996
reviewed
Sep 23, 2026
Jordanh1996
reviewed
Sep 23, 2026
Jordanh1996
approved these changes
Sep 23, 2026
…arens format, multi-declaration and quote-style gaps Fixes 6 issues raised on the Poetry package updater: a oneline PEP 621 array losing sibling deps to the shared range regex's unbounded match, poetry.lock not being accepted as evidence (root cause was missing from Poetry's packageDescriptors in techutils.go), the "name (>=x,<y)" form Poetry 2 writes, manifest/lock name separator mismatches, only the first of multiple declarations getting pinned, and single-quoted constraints. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Jordanh1996
approved these changes
Sep 24, 2026
…endencies
Handles 3 more gaps a teammate found: PEP 621 extras ("requests[socks]")
were dropped instead of preserved, an environment marker's embedded
single quote truncated the fix into invalid TOML, and Poetry's
multiple-constraints-dependencies form (name = [{...}, {...}]) wasn't
matched at all.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…eature/poetry-fix-support
This branch had an error being 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.
devbranch.go vet ./....go fmt ./....handlePoetryranpoetry add <pkg>==<ver>, which rewrites whatever constraint form was declared (range, table-with-extras, group) into an exact pin, then a barepoetry update, which is unscoped (drifts unrelated transitives) and, without--lock, installs into the environment. It also ran in the process working directory rather than the project the finding's evidence points at.Fix
Replaced with the verified sequence: pin the dependency to the exact fix version wherever its existing declaration actually is (bare string, table-with-extras, group table, or PEP 621 native array entry) — never via
poetry add, which duplicates the dependency into the main table when it actually lives in a group (verified live). Then a scopedpoetry update <pkg> --lock --no-interaction, restore the manifest verbatim, and re-sync the lock's content-hash without re-resolving (poetry lockon 2.x,poetry lock --no-updateon 1.x — the flag's meaning inverted as Poetry 2.0's new default). If the original constraint doesn't admit the fix version, restoring it verbatim silently reverts the lock whilepoetry check --lockstill exits 0 (verified with jinja2^2.11and a fix of 3.1.6) — widen by re-applying the exact pin instead, and assert the locked version directly rather than trusting that exit code.Runs via
cmd.Dirresolved from the finding's evidence, never the process cwd, matching the existing Yarn/Go/Npm updaters' convention. Never setscmd.Env, so private-index credentials are inherited from whatever environment the customer's own CI already provides.Verification
[tool.poetry.dependencies]with a range that admits the fix version:pyproject.tomlunchanged, onlypoetry.lockupdates.^2.11→3.1.6): constraint widened to the exact pin, locked version verified directly.[tool.poetry.group.dev.dependencies]: fixed in place, no duplication into the main table (the bugpoetry addhas).pyproject.tomlbyte-identical,poetry.lockupdatedAdded regression tests for all three, plus dedicated testdata fixtures. Existing
poetry-direct-deptest updated to supply evidence, since the fix no longer relies oncwd. Full suite passes except a pre-existing, unrelatedpipenvfailure (binary not installed in this sandbox).