`extract()` raises `ValueError` on Windows when a symbol-less file and `root` are on different drives (regression in 0.9.75)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #4106 của @xiehuanyi — đã đóng, không merge
Đá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
- 88/100
Hướng nghiên cứu
Bắt đầu trong graphify/extract.py, tại phần xây dựng đường dẫn _symbolless_files, và xem xét cách root được chọn khi chỉ truyền cache_root. Tái hiện trường hợp giữa các ổ đĩa trên Windows, sau đó chạy tests/test_languages.py::test_objc_bridging_header_not_isolated, tests/test_languages.py::test_objc_paired_no_dangling_edges và tests/test_partial_extraction_warning.py. Hoàn tất khi quá trình trích xuất không còn bị hủy giữa các ổ đĩa và các bài kiểm thử bị ảnh hưởng đều đạt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
The "cleanly parsed code file yields no symbols" warning added in 0.9.75 (#4009, fixes #3946) builds the displayed path with an unguarded os.path.relpath in graphify/extract.py:
_symbolless_files.append((os.path.relpath(str(_p), str(root)).replace("\\", "/"), _size))
On Windows os.path.relpath raises ValueError: path is on mount 'D:', start on mount 'C:' when the file and root are on different drives, so a diagnostic warning aborts the whole extraction.
The automated review on #4009 already flagged this risk ("os.path.relpath can raise ValueError and crash extract() for out-of-root paths on Windows", medium severity). This issue adds a concrete reproduction, the affected tests, and a verified fix.
Environment
Windows 11, Python 3.12.13, graphify v0.9.75 (48d7c0e8).
Reproduction
root is not passed, so extract() falls back to cache_root (elif cache_root is not None: root = cache_root).
import tempfile
from pathlib import Path
from graphify.extract import extract
p = Path(r"D:\proj\a.py") # contains only: "# comment\nX = 1\n" -> the file yields exactly 1 node
with tempfile.TemporaryDirectory() as td: # %TEMP% is on C:
extract([p], cache_root=Path(td))
Result on v0.9.75:
ValueError: path is on mount 'D:', start on mount 'C:'
- On v0.9.74 the same call succeeds.
- On v0.9.75 the same call succeeds when
root=p.parentis passed explicitly. - The test suite hits it too when the checkout is on a different drive from
%TEMP%:tests/test_languages.py::test_objc_bridging_header_not_isolatedandtests/test_languages.py::test_objc_paired_no_dangling_edgesfail, because the_corpus()helper passes onlycache_root=<tmp dir>. A clean v0.9.75 checkout onD:gives 2 failed; the same checkout onC:gives 2 passed.
Scope
- The
graphify extractCLI is not affected: it passesroot=targetexplicitly (ast_kwargs: dict = {"cache_root": out_root, "root": target}). Checked end to end with the repo onD:,GRAPHIFY_OUTonC:and one symbol-less.pyfile: the warning is printed,graph.jsonis written, exit code 0. - Affected: callers of
extract()that passcache_rootwithoutrooton a different drive from the scanned files, and the test suite on Windows checkouts outside the temp drive.
Suggested fix
try:
_rel = os.path.relpath(str(_p), str(root)).replace("\\", "/")
except ValueError: # different drive on Windows
_rel = _p.as_posix()
_symbolless_files.append((_rel, _size))
Applied to a clean v0.9.75 checkout on D:: the reproduction above succeeds, the -k objc tests in tests/test_languages.py pass (33 passed), and tests/test_partial_extraction_warning.py passes (11 passed).
- Ngôn ngữ chính
- Python
- Star
- 124k
- Fork
- 11.9k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 Graphify-Labs/graphify
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Graphify-Labs/graphify#4524 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] Pi skill uses unsupported general-purpose subagent instead of delegateCó thể đã có người làm @bercedev đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Graphify-Labs/graphify#4494 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ID collision: a node with no source_file beats a sourced node with the same id (dedup._collision_rank)Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Graphify-Labs/graphify#4492 · 1 bình luận ·
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 86/100
Graphify-Labs/graphify#3763 ·
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 78/100
Graphify-Labs/graphify#3611 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Graphify-Labs/graphify
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
topoteretes/cognee#5982 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Patches of derivations with `__structuredAttrs` are ignoredCó thể đã có người làm @KiaraGrouwstra đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 81/100
nix-community/vulnix#184 ·
-
New InternshipĐang mởnew_internship
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
aws-samples/sample-per-model-bedrock#295 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
pyrevitlabs/pyRevit#3792 ·
Maintainer thường phản hồi trong vòng 1 ngày