A TypeScript or JavaScript file whose name is not valid UTF-8 fails the delta pass
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ó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, python, typescript
- Lĩnh vực
- backend, data-engineering
Hướng nghiên cứu
Start with scip_to_delta.py around lines 1395–1398 and 1463–1465, then trace the delta wire format through server/code/app/index/delta_file.py around line 161 and the worker at server/code/workers/scip_ts_delta.py. The issue leaves the wire behavior to a maintainer decision: choose whether to encode, skip, or reject invalid UTF-8 paths before changing the converter. Done means the selected behavior lets the pass handle these names consistently without producing a delta the server cannot parse.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
TL;DR: A TypeScript or JavaScript file whose own name is not valid UTF-8 stops the member delta pass. The converter's window-list read raises UnicodeDecodeError and no delta is written, so the watermark stays and the next pass fails the same way. Decoding the name with os.fsdecode alone moves the failure to the server, so carrying such names needs a byte-safe path form in the delta wire format, which is a maintainer decision.
Company
Independent
Component
Code index
Describe the situation
This is the part of closed #1959 (item 3) that #1963 did not cover. #1963 made the project filter read the window lists byte-safe (scip_ts_projects.py:287-294); the converter still reads them as strict UTF-8.
On upstream/main at 82dc31216fd252db028fa57eca570fe87258e64a:
git_pathswrites a name as the tree stores it (core.quotePath=false,scripts/scip_harness/lib.sh:60-69), andwindow_filesputs the TypeScript and JavaScript names intochanged.txtanddeleted.txt(lib.sh:76-85, called fromrun_typescript_delta.sh:190).- The converter reads both lists with
Path(path).read_text()(scip_to_delta.py:1395-1398, called at:1463and:1465). A name holding byte 0xff or 0xfe raisesUnicodeDecodeError,run_typescript_delta.shexits 1 and noDELTA_OUTfile is written. An added or edited file and a deleted file fail the same way; I ran each. - The worker raises
harness_failurefrom_run_harness(server/code/workers/scip_ts_delta.py:253-254) before it sets the watermark (:154and:168), so the entry's watermark stays. The next pass uses the same base, and the window fails again for as long as the net diff from the watermark names the file. - With
os.fsdecodein_path_list(a local patch I made to test this), the pass succeeds, but a deleted name reachesdeleted_filesas a lone surrogate.scip_to_delta.pywrites it withjson.dumps(:1312-1320) as"src/bad\udcff.ts", and the server's delta parse (pydantic_core.from_json,server/code/app/index/delta_file.py:161) refuses it:lone leading surrogate in hex escape at line 3 column 33. The server would refuse the whole delta. - In a
--fullpass over a tree that holds such a file, scip-typescript 0.4.0 emits no document for it: a fixture with three TypeScript files, one namedsrc/bad\xff.ts, converts to 2 files. So no compiler-tier row exists for such a file, and an added or changed one is absent fromfileswith or without the patch. I did not check what the fast tier does with the name.
Does it reproduce on the latest release or main?
Yes
How to reproduce
From a checkout of main, with the server's virtualenv first on PATH, @sourcegraph/scip-typescript 0.4.0 installed, and SCIP_TYPESCRIPT set to its binary:
L=$PWD; W=$(mktemp -d) && cd "$W" && git init -q fx && cd fx
git config user.email a@b && git config user.name t
printf '{"name":"fx"}' > package.json
printf '{"compilerOptions":{"target":"es2022","module":"nodenext","moduleResolution":"nodenext","strict":true},"include":["src"]}' > tsconfig.json
mkdir src && echo 'export const a = 1;' > src/a.ts
git add -A && git commit -qm base && BASE=$(git rev-parse HEAD)
printf 'export const z = 1;\n' > "$(printf 'src/new\xfe.ts')"
git add -A && git commit -qm head && HEAD=$(git rev-parse HEAD)
cd "$L"
DELTA_OUT=$W/d.json scripts/scip_harness/run_typescript_delta.sh "$W/fx" "$BASE" "$HEAD"
# UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfe in position 7: invalid start byte
# exit 1, no $W/d.json
The same failure with the file deleted: commit src/bad\xff.ts in the base, git rm it in the head, and run the window.
The server side: with os.fsdecode(Path(path).read_bytes()) in place of read_text() in _path_list, the window above passes and writes $W/d.json. For a window that deletes src/bad\xff.ts its deleted_files entry is the lone surrogate:
python3 -c "import pydantic_core,sys; pydantic_core.from_json(open(sys.argv[1],'rb').read())" "$W/d.json"
# ValueError: lone leading surrogate in hex escape at line 3 column 33
Expected behavior
- A name that is not valid UTF-8 does not fail the pass. The wire format needs a decision on how the delta carries or omits it; the options I see:
- An escaped or base64 path field next to
pathand indeleted_filesandskipped_files, so the name survives the JSON parse. This keeps tombstones for a file that did have rows, but no compiler-tier row exists for such a file today (item 5 above). - Skip the file with a stated warning: the converter drops the name from both lists, names it on stderr as it does for a skipped document, and the pass advances. Nothing is lost that the compiler tier held.
- Refuse it at ingest: the converter fails with a message that names the file, instead of a
UnicodeDecodeErrortraceback. The pass still stops, but the log says why.
- An escaped or base64 path field next to
- Whichever is chosen,
_path_listreads bytes (os.fsdecodeorsurrogateescape), as_read_linesinscip_ts_projects.pyalready does, so the name never reachesread_text.
The choice between these is the maintainers'. Decoding with os.fsdecode alone is not enough (item 4).
Environment
Loom main at 82dc31216fd252db028fa57eca570fe87258e64a.
@sourcegraph/scip-typescript 0.4.0, node 22.23.4, Python 3.12, git 2.43.
run_typescript_delta.sh in DELTA_OUT mode, the worker's mode; no ClickHouse involved.
Linux; a one-package fixture.
Related issues and pull requests
Related: https://github.com/ClickHouse/loom/issues/1959
Related: https://github.com/ClickHouse/loom/pull/1963
Related: https://github.com/ClickHouse/loom/pull/1782
Additional context
How this was found
Found and reproduced with AI assistance.
Redaction
- I removed tokens, keys, passwords and personal or customer data from everything above.
- Ngôn ngữ chính
- Python
- Star
- 263
- Fork
- 47
- Merge trung bình
- 14 giờ 21 phút
- Pull request đã merge (30 ngày)
- 873
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- 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 ClickHouse/loom
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 76/100
ClickHouse/loom#2014 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Options of loom period-digest, reextract, reconcile-status and demote-activity-narration print no help textCó thể đã có người làm @VanshajPoonia đã nhận hôm nay. Đang mởbug good first issue help wanted up-for-grabs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
ClickHouse/loom#1988 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A compiler-tier checkout fetch from a shallow mirror never records its headCó thể đã có người làm @KaloyanNaumov đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
ClickHouse/loom#2016 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Delta workers fetch the compiler-tier checkout under a hard-coded 600 s limitCó thể đã có người làm @KaloyanNaumov đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 35/100
ClickHouse/loom#2012 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
loom participant retire cannot retire an orphaned participant after container replacement or host rebootCó thể đã có người làm @l0K1ngg đã nhận hôm nay. Đang mởbug help wanted up-for-grabs
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
ClickHouse/loom#2007 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ClickHouse/loom
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
TigreGotico/orthography2ipa#2950 ·
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
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Unstructured-IO/unstructured#4876 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
openfoodfacts/openfoodfacts-python#579 ·
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 90/100
fairagro/m4.2_sql_to_arc#388 ·
Maintainer thường phản hồi trong vòng 1 ngày