edit_file diff rendering panics on invalid UTF-8 text
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 85/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- go
- Área
- testing-qa
Línea de trabajo
Empieza por pkg/tui/components/tool/editfile/render.go, especialmente por wrapTokens cerca de la línea 520 indicada, y reproduce el pánico con la entrada descrita a\xff. Añade una prueba de regresión para UTF-8 no válido en wrapTokens. Después, verifica que el diff se renderice sin provocar un pánico y ejecuta la prueba del paquete editfile.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Go
- Estrellas
- 4.7k
- Forks
- 565
- Merge medio
- 18 h 52 min
- PR fusionados (30 d)
- 221
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de docker/docker-agent
-
A setting to turn off the models.dev catalog download (offline and strict-network use)Posiblemente ocupada @3431481073 la tomó hace 19 días. Abiertoarea/config area/models
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
docker/docker-agent#4714 ·
Los mantenedores suelen responder en 1 día
-
Error when trying to run sandbox example?Posiblemente ocupada @dgageot la tomó hace 27 días. Abiertoarea/cli
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
docker/docker-agent#4672 · 1 comentario · 1 reacción · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
`edit_file` silently edits the first match when `oldText` occurs more than oncePosiblemente ocupada @dwin-gharibi la tomó hace 103 días. Abiertoarea/tools
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
docker/docker-agent#3929 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
area/api area/runtime
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
docker/docker-agent#4951 ·
Los mantenedores suelen responder en 1 día
-
area/agent area/cli area/runtime
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
docker/docker-agent#4947 ·
Los mantenedores suelen responder en 1 día
Todos los issues de docker/docker-agent
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
OneBusAway/maglev#2145 ·
Los mantenedores suelen responder en 2 días
-
priority/medium status/ready type/chore
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
discobox-ai/discobox#1357 ·
Los mantenedores suelen responder en 1 día
-
TestPseudoLocaleRemote fails now and then: it types the code before the laptop asks for itPosiblemente ocupada @fzn0x la tomó hoy. Abiertobug priority: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
enhancement ui/ux
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
jbigler/railswitch#243 ·
Los mantenedores suelen responder en 1 día
-
Helm probes fail when DCGM Exporter requires TLS client certificatesPosiblemente ocupada @git-jxj la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
NVIDIA/dcgm-exporter#775 ·
Los mantenedores suelen responder en 1 día