edit_file diff rendering panics on invalid UTF-8 text
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 85/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- go
- Domaine
- testing-qa
Piste de recherche
Commence par pkg/tui/components/tool/editfile/render.go, en particulier par wrapTokens autour de la ligne 520 signalée, et reproduis le panic avec l’entrée décrite a\xff. Ajoute un test de régression pour l’UTF-8 invalide dans wrapTokens. Vérifie ensuite que le diff s’affiche sans provoquer de panic et exécute le test du package editfile.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Go
- Étoiles
- 4.7k
- Forks
- 565
- Merge moyen
- 18 h 52 min
- PR mergées (30 j)
- 221
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Fournit un Dockerfile ou un fichier Docker Compose
- Aucun modèle de pull request
- Aucun guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de docker/docker-agent
-
A setting to turn off the models.dev catalog download (offline and strict-network use)Peut-être pris @3431481073 l’a pris il y a 19 jours. Ouvertearea/config area/models
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
docker/docker-agent#4714 ·
Les mainteneurs répondent en général sous 1 jour
-
Error when trying to run sandbox example?Peut-être pris @dgageot l’a pris il y a 27 jours. Ouvertearea/cli
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
docker/docker-agent#4672 · 1 commentaire · 1 réaction · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
`edit_file` silently edits the first match when `oldText` occurs more than oncePeut-être pris @dwin-gharibi l’a pris il y a 103 jours. Ouvertearea/tools
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
docker/docker-agent#3929 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
area/api area/runtime
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
docker/docker-agent#4951 ·
Les mainteneurs répondent en général sous 1 jour
-
area/agent area/cli area/runtime
Difficulté 4/5 3-5 jours Accessibilité débutants 55/100
docker/docker-agent#4947 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de docker/docker-agent
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
OneBusAway/maglev#2145 ·
Les mainteneurs répondent en général sous 2 jours
-
priority/medium status/ready type/chore
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
discobox-ai/discobox#1357 ·
Les mainteneurs répondent en général sous 1 jour
-
TestPseudoLocaleRemote fails now and then: it types the code before the laptop asks for itPeut-être pris @fzn0x l’a pris aujourd’hui. Ouvertebug priority: low
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 1 jour
-
enhancement ui/ux
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
jbigler/railswitch#243 ·
Les mainteneurs répondent en général sous 1 jour
-
Helm probes fail when DCGM Exporter requires TLS client certificatesPeut-être pris @git-jxj l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
NVIDIA/dcgm-exporter#775 ·
Les mainteneurs répondent en général sous 1 jour