edit_file diff rendering panics on invalid UTF-8 text
Maintainer thường phản hồi trong vòng 1 ngà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
- 85/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go
- Lĩnh vực
- testing-qa
Hướng nghiên cứu
Bắt đầu với pkg/tui/components/tool/editfile/render.go, đặc biệt là wrapTokens gần dòng 520 được báo cáo, và tái hiện panic với đầu vào a\xff đã mô tả. Thêm một bài kiểm thử hồi quy cho UTF-8 không hợp lệ trong wrapTokens. Sau đó, xác minh rằng diff được hiển thị mà không gây panic và chạy bài kiểm thử của gói editfile.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
The edit-diff / confirmation-preview renderer crashes the whole TUI when the edited file contains invalid UTF-8 bytes (Latin-1 sources, GBK comments, binary-ish files).
wrapTokens (pkg/tui/components/tool/editfile/render.go:495-525) wraps syntax-highlighted tokens to a width. It accumulates the taken bytes with utf8.RuneLen(r) while iterating for _, r := range text — range decodes an invalid byte as U+FFFD consuming one source byte, but utf8.RuneLen(U+FFFD) is 3, so fitLen overcounts and text[:fitLen] slices past the string (:520).
Verified minimal repro (a file containing the bytes a\xff), from a unit test against the real package:
$ go test ./pkg/tui/components/tool/editfile -run TestWrapTokensInvalidUTF8
panic: runtime error: slice bounds out of range [:4] with length 2
...editfile.wrapTokens(...) render.go:520
Reachability: handleEditFile has no binary-content guard before persisting the result meta, and the in-process EditFileMeta reaches the renderer without a JSON roundtrip that would sanitize invalid bytes, so any edit_file on such a file panics the bubbletea View and kills the process.
Expected Behavior
Rendering an edit diff never panics; invalid bytes render safely (highlighted or replaced).
Actual Behavior
The process panics with slice bounds out of range mid-render.
Steps to Reproduce
- Create a file whose content includes an invalid UTF-8 byte (e.g. a Latin-1
ésaved as0xE9, orprintf 'a\xff' > /tmp/x.txt). - Ask an agent to
edit_fileit. - The confirmation/diff view panics.
Docker Agent version
No response
OS & terminal
No response
Model used
No response
Error output
Screenshots
No response
Additional context
Fix: take the byte length from the range position (for i, r := range text with the rune's encoded size) or decode with utf8.DecodeRuneInString; add a wrapTokens test with invalid UTF-8. Verified on main @ 19a735644. Happy to submit the fix.
- Ngôn ngữ chính
- Go
- Star
- 4.7k
- Fork
- 565
- Merge trung bình
- 18 giờ 52 phút
- Pull request đã merge (30 ngày)
- 221
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
- Không có mẫu pull request
- Không 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 docker/docker-agent
-
A setting to turn off the models.dev catalog download (offline and strict-network use)Có thể đã có người làm @3431481073 đã nhận 19 ngày trước. Đang mởarea/config area/models
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
docker/docker-agent#4714 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Error when trying to run sandbox example?Có thể đã có người làm @dgageot đã nhận 27 ngày trước. Đang mởarea/cli
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
docker/docker-agent#4672 · 1 bình luận · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`edit_file` silently edits the first match when `oldText` occurs more than onceCó thể đã có người làm @dwin-gharibi đã nhận 103 ngày trước. Đang mởarea/tools
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
docker/docker-agent#3929 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/api area/runtime
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
docker/docker-agent#4951 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/agent area/cli area/runtime
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
docker/docker-agent#4947 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của docker/docker-agent
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
OneBusAway/maglev#2145 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
priority/medium status/ready type/chore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
discobox-ai/discobox#1357 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
TestPseudoLocaleRemote fails now and then: it types the code before the laptop asks for itCó thể đã có người làm @fzn0x đã nhận hôm nay. Đang mởbug priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement ui/ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jbigler/railswitch#243 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Helm probes fail when DCGM Exporter requires TLS client certificatesCó thể đã có người làm @git-jxj đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
NVIDIA/dcgm-exporter#775 ·
Maintainer thường phản hồi trong vòng 1 ngày