NuGet crawler test crawls the host's ~/.nuget/packages and fails on dev machines
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Đọc crates/socket-patch-core/src/crawlers/nuget_crawler.rs, đặc biệt là bài kiểm thử solution_roots_and_unrestored_projects_keep_the_walk và bài kiểm thử NUGET_PACKAGES gần dòng 1450; xem crate::test_env::EnvGuard để tìm hiểu mẫu cô lập môi trường hiện có. Chạy lệnh cargo test từ issue để tái hiện và xác minh bản sửa lỗi. Hoàn tất khi cả hai bài kiểm thử đều dùng các thiết lập môi trường được bảo vệ và chạy thành công mà không đọc thư mục gói NuGet của máy chủ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
LLM Description written by Claude Code:claude-opus-5-5
Summary
crawlers::nuget_crawler::tests::solution_roots_and_unrestored_projects_keep_the_walk (crates/socket-patch-core/src/crawlers/nuget_crawler.rs:1978) is not hermetic. It crawls the real global packages folder of the machine running it, so it fails on any developer machine whose ~/.nuget/packages holds a package. It passes in CI only because the runners' NuGet cache is empty.
Repro
On main (7bde3ba5), on a machine with any package in ~/.nuget/packages:
cargo test --locked -p socket-patch-core --lib solution_roots_and_unrestored_projects_keep_the_walk
panicked at crates/socket-patch-core/src/crawlers/nuget_crawler.rs:1994:9:
left: ["pkg:nuget/[email protected]", "pkg:nuget/[email protected]", "pkg:nuget/[email protected]", "pkg:nuget/[email protected]"]
right: ["pkg:nuget/[email protected]", "pkg:nuget/[email protected]", "pkg:nuget/[email protected]"]
The extra purl comes from the host's ~/.nuget/packages/socketsecurity.socketpatch/3.3.0. The test fails every time on such a machine, and passes with an isolated home:
HOME=$(mktemp -d) CARGO_HOME=~/.cargo RUSTUP_HOME=~/.rustup \
cargo test --locked -p socket-patch-core --lib solution_roots_and_unrestored_projects_keep_the_walk
# test result: ok. 1 passed
Root cause
In project mode, crawl_roots always adds the global packages folder NuGet would restore into as search root 3 (nuget_crawler.rs:626-630, via global_packages_folder → nuget_home(), which falls back to $DOTNET_CLI_HOME or ~/.nuget/packages). A solution root, or a project that hasn't been restored, has no restore scope (roots.scope is set only for DotnetRoot::Project), so every package in that folder is crawled.
The test builds its packages in a temp shared-cache named by packageFolders, but leaves NUGET_PACKAGES and DOTNET_CLI_HOME unset. Its expected list (every) therefore assumes the host's default folder is empty or missing.
Suggested fix
Run the crawl under the existing crate::test_env::EnvGuard, with NUGET_PACKAGES pointed at an empty directory inside the test's tempdir (and DOTNET_CLI_HOME cleared). That makes root 3 hermetic without changing the crawler.
The NUGET_PACKAGES test around nuget_crawler.rs:1450 sets and removes the variable with bare std::env::set_var/remove_var, outside the guard. It should move onto EnvGuard too, so a parallel crawl test can't observe the variable while it's set.
Note
The product behavior the test pins, where a solution-root or unrestored-project crawl includes every package in the user's global folder, is the unscoped "today's walk" that #427 / #1183 deliberately kept for those roots. This issue is only about the test's isolation.
Found while validating #2015.
- Ngôn ngữ chính
- Rust
- Star
- 9
- Fork
- 2
- Merge trung bình
- 20 giờ 9 phút
- Pull request đã merge (30 ngày)
- 629
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SocketDev/socket-patch
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
SocketDev/socket-patch#1860 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
SocketDev/socket-patch#1838 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Nightly gem e2e red on bundler 1.17/2.1: CRLF source-block rollback unattributableCó thể đã có người làm @mikolalysenko đã nhận 2 ngày trước. Đang mởci-janitor
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
SocketDev/socket-patch#1997 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
arch-audit refactor
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 54/100
SocketDev/socket-patch#1993 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
arch-audit refactor
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 66/100
SocketDev/socket-patch#1992 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của SocketDev/socket-patch
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
apache/datafusion-iceberg#100 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: cua-driver skill fails Agent Skills frontmatter validationCó thể đã có người làm @Mearman đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area/tools bug session-analysis
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
oracle/rust-oracledb#66 ·
-
`PrimitiveArray::validate_decimal_precision` rejects every decimal array with a negative scaleĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày