socket fix (Poetry): an exact pin on a direct dependency blocks the fix of its transitive dependency, and the diagnostic wrongly says there is no upgrade path
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 22/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python, typescript
调研方向
Reproduce with the exact and control zips using the steps in the issue, and read the --debug output of the failing run. Search the source for the "no upgrade path through the dependency tree" message and for the code that adds a direct constraint on the vulnerable transitive package before running poetry lock. Done means the exact run either raises opentelemetry-sdk to 1.45.1 or names the blocking direct constraint and its required version, and the misleading diagnostic no longer appears.
由索引模型根据 Issue 内容生成。
描述
Summary
socket fix reports GHSA-xcq7-p3pf-p88h on opentelemetry-api 1.36.0 (fixed in 1.45.1), pulled in by opentelemetry-sdk. When the project pins opentelemetry-sdk to an exact version ("1.36.0"), the fix fails: Coana only tries to raise the transitive opentelemetry-api, and never the direct dependency opentelemetry-sdk, which itself requires opentelemetry-api==1.36.0. Raising opentelemetry-sdk to 1.45.1 is a minor update and is the only way to fix the advisory.
This is one bug. The second zip is a control: same lock file, only the constraint differs ("^1.36.0"), and the same run succeeds, Poetry moving opentelemetry-sdk and opentelemetry-semantic-conventions along with opentelemetry-api. This shows that the exact pin is the only cause, and that the diagnostic printed in both cases ("no version of opentelemetry-semantic-conventions is compatible", "no upgrade path through the dependency tree") is wrong.
| Zip | pyproject.toml |
Result | Exit code |
|---|---|---|---|
exact (bug) |
opentelemetry-sdk = "1.36.0" |
❌ Poetry could not upgrade opentelemetry-api to 1.45.1, 0/1 workspaces were upgraded successfully, Coana command failed (exit code 3); working tree unchanged |
1 |
control (works) |
opentelemetry-sdk = "^1.36.0" |
✅ Locked opentelemetry-api 1.45.1, 1/1 workspaces were upgraded successfully, Finished!; poetry.lock moves opentelemetry-api/-sdk 1.36.0 to 1.45.1 and opentelemetry-semantic-conventions 0.57b0 to 0.66b1 |
0 |
Environment
| Socket CLI | 1.12.1 |
| Coana CLI (bundled) | 15.13.3 |
| OS | WSL2, Debian GNU/Linux 12 (bookworm), kernel 5.15.133.1-microsoft-standard-WSL2 |
| Node.js / npm | v23.11.1 / 10.9.2 |
| Poetry | 2.5.1 |
| Python | 3.11.2 |
| Package index | PyPI (default) |
Attachments
- socket-poetry-pin-repro-exact.zip:
pyproject.toml,poetry.lock - socket-poetry-pin-repro-control.zip:
pyproject.toml,poetry.lock
pyproject.toml (exact; control has opentelemetry-sdk = "^1.36.0"):
[tool.poetry]
name = "repro"
version = "0.1.0"
package-mode = false
[tool.poetry.dependencies]
python = ">=3.10,<4.0"
opentelemetry-sdk = "1.36.0"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Both poetry.lock files were generated by poetry lock and contain the same versions: opentelemetry-api 1.36.0, opentelemetry-sdk 1.36.0, opentelemetry-semantic-conventions 0.57b0, importlib-metadata 8.7.1, typing-extensions 4.16.0, zipp 4.1.2 (poetry check --lock passes).
Steps to reproduce
for v in exact control; do
d=socket-poetry-pin-repro-$v
unzip -q "$d.zip" && cd "$d"
git init -q && git add -A && git commit -qm repro # only to see the diff afterwards
socket fix . --all
echo "$v: exit=$?"
git --no-pager diff --stat
cd ..
done
Expected
exact: opentelemetry-sdk is raised to 1.45.1 in pyproject.toml (a minor update, allowed even with --no-major-updates) and poetry.lock gets opentelemetry-api 1.45.1, opentelemetry-sdk 1.45.1 and opentelemetry-semantic-conventions 0.66b1. Exit code 0.
If raising a direct dependency is out of scope, the run should at least say which direct constraint blocks the fix and what it must be raised to (opentelemetry-sdk pinned to 1.36.0 in pyproject.toml, 1.45.1 required), instead of reporting that no upgrade path exists.
In both zips, the diagnostic should not claim that no version of opentelemetry-semantic-conventions is compatible with the patched opentelemetry-api.
Actual
Both zips print the same analysis first:
info: Unable to compute fixes for some vulnerabilities:
info: - GHSA-xcq7-p3pf-p88h:
info: • pkg:pypi/[email protected]?artifact_id=tar-gz (via pkg:pypi/[email protected]?artifact_id=tar-gz -> pkg:pypi/[email protected]?artifact_id=tar-gz)
info: ⚠ pkg:pypi/opentelemetry-api has safe versions (the lowest is 1.45.1), but no version of pkg:pypi/opentelemetry-semantic-conventions (installed 0.57b0) is compatible with them. There is no upgrade path through the dependency tree — applying this fix would require an override (e.g. pnpm overrides) forcing pkg:pypi/opentelemetry-semantic-conventions to accept a patched version of pkg:pypi/opentelemetry-api.
info: Upgrading purls for .../socket-poetry-pin-repro-<exact|control>:
pkg:pypi/[email protected] → 1.45.1
exact (with --debug):
debug: Running command: poetry lock in .../socket-poetry-pin-repro-exact
debug: Poetry stderr
Because opentelemetry-sdk (1.36.0) depends on opentelemetry-api (1.36.0)
and repro depends on opentelemetry-api (1.45.1), opentelemetry-sdk is forbidden.
So, because repro depends on opentelemetry-sdk (1.36.0), version solving failed.
debug: Running command: poetry lock in .../socket-poetry-pin-repro-exact
info: ❌ Poetry could not upgrade opentelemetry-api to 1.45.1: Because opentelemetry-sdk (1.36.0) depends on opentelemetry-api (1.36.0) ─ poetry.lock
debug: Error stack: UpgradePurlPartialError: Some workspaces failed to upgrade
0/1 workspaces were upgraded successfully.
Failed workspaces:
- poetry.lock
✖ Coana command failed (exit code 3): command failed
Exit code 1. The working tree is left unchanged (the change is reverted correctly).
control:
info: ✅ Locked opentelemetry-api 1.45.1 ─ poetry.lock
info: └─ pkg:pypi/[email protected] → 1.45.1
1/1 workspaces were upgraded successfully.
✔ Finished!
Exit code 0. Only poetry.lock changes: opentelemetry-api and opentelemetry-sdk 1.36.0 to 1.45.1, opentelemetry-semantic-conventions 0.57b0 to 0.66b1 (importlib-metadata and zipp are dropped). pyproject.toml is unchanged and poetry check --lock passes.
Analysis
- Poetry's error shows the strategy: a direct constraint
repro depends on opentelemetry-api (1.45.1)is added for the vulnerable transitive package, thenpoetry lockis run. Withopentelemetry-sdk = "1.36.0"in the root, which requiresopentelemetry-api==1.36.0, this cannot be solved. The blocking constraint is a direct dependency declared in the user's ownpyproject.toml, and raising it within the same major version is enough, but this is never attempted. - The
controlrun proves that an upgrade path exists:opentelemetry-semantic-conventions0.66b1 acceptsopentelemetry-api1.45.1, and Poetry picks it. The analysis appears to only consider the installed version of the intermediate packages (installed 0.57b0), not newer ones. - The same advisory is listed under "Unable to compute fixes" and then fixed successfully in
control, which makes the output contradictory. - The suggested remedy ("an override (e.g. pnpm overrides)") does not apply to Poetry, which has no override mechanism.
Real-world impact
OpenTelemetry Python packages require exact versions of each other (opentelemetry-sdk 1.36.0 requires opentelemetry-api==1.36.0, opentelemetry-semantic-conventions==0.57b0), so applications commonly pin the whole family to exact versions to keep it consistent. On our project, five OpenTelemetry packages are pinned this way (opentelemetry-api, opentelemetry-sdk, opentelemetry-exporter-otlp at 1.36.0; opentelemetry-distro, opentelemetry-instrumentation-fastapi at 0.57b0). socket fix . --all --no-major-updates --ecosystems pypi --package-managers poetry fails exactly as in the exact zip. The fix had to be applied by hand: raise the whole family to 1.45.1 / 0.66b1, then poetry lock; the test suite passes.
Suggested fix
When a transitive upgrade is blocked by the constraint of a direct dependency in the manifest, raise that direct dependency to the lowest version that accepts the patched transitive version (here opentelemetry-sdk 1.45.1), within the limits of --no-major-updates.
- 主要语言
- TypeScript
- 星标
- 335
- 派生
- 74
- 平均合并
- 1 天 11 小时
- 30 天内合并 PR
- 86
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
SocketDev/socket-cli 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
SocketDev/socket-cli#1655 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
SocketDev/socket-cli#1160 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 3/5 半天 新手友好度 38/100
SocketDev/socket-cli#1690 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 15/100
SocketDev/socket-cli#1688 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
SocketDev/socket-cli#1675 ·
维护者通常 1 天内回复
查看 SocketDev/socket-cli 的全部 Issue
相似的 Issue
-
Remove unused dependencies可能已有人在做 @alastair-smith 今天认领。 未关闭chore other
难度 2/5 1-3 小时 新手友好度 78/100
alastair-smith/card-games#384 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
code-yeongyu/senpi#5571 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
nexu-io/open-design#9262 · 1 条评论 ·
维护者通常 1 天内回复
-
friction
难度 2/5 1-3 小时 新手友好度 72/100
kentcdodds/kody#4753 ·
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 1/5 1 小时以内 新手友好度 62/100
lingdojo/kana-dojo#33508 · 1 条评论 · 5 个 reaction ·
维护者通常 1 天内回复