create_or_update_file writes to the wrong file when the path contains # or ?
I maintainer di solito rispondono entro 4 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
Direzione di ricerca
Inizia in pkg/github/repositories.go in CreateOrUpdateFile (v1.14.0 / 71ef8266), dove la chiamata CreateFile passa path non escapeato, e leggi escapeGitTreeish come schema esistente per l'escape per segmento. Confronta con i controlli di esistenza e symlink basati su GetContents, che già fanno l'escape correttamente. Il risultato assomiglia a PUT /repos/{owner}/{repo}/contents/docs/C%23/intro.md su un server mock, più un test di regression (estendi il file di test repositories esistente) che verifichi che i percorsi # e ? vengano scritti nel file giusto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
create_or_update_file with path: "docs/C#/intro.md" commits the content to a file named docs/C and reports success. A ? does the same (notes/what?.md is written as notes/what).
The path goes into the request URL unescaped: go-github's RepositoriesService.CreateFile builds repos/{owner}/{repo}/contents/{path} with no escaping, so everything from # on becomes a URL fragment and everything from ? on becomes a query string. The checks that run first (the existing-file / SHA lookup and the symlink check) go through GetContents, which does escape the path, so they look at the right file while the write goes to another.
Affected version
v1.14.0 and main at 71ef8266 (pkg/github/repositories.go, the CreateFile call in CreateOrUpdateFile).
Steps to reproduce the behavior
- Call
create_or_update_fileon a test repository:{"owner":"<you>","repo":"<test repo>","path":"docs/C#/intro.md","content":"# Intro","message":"Add intro","branch":"main"} - Look at the commit.
Expected vs actual behavior
Expected: a file at docs/C#/intro.md (the request goes to PUT /repos/<you>/<test repo>/contents/docs/C%23/intro.md).
Actual: the request goes to PUT /repos/<you>/<test repo>/contents/docs/C, the commit creates a file named docs/C, and the tool result reports success with "path": "docs/C". If docs/C already exists as a file, it is overwritten.
Logs
Request seen by a mock server for the call above:
GET /repos/owner/repo/contents/docs/C%23/intro.md -> 404 (existence check, escaped)
PUT /repos/owner/repo/contents/docs/C (the write, unescaped)
I have a small fix with a regression test ready and can open a PR: escape each path segment before calling CreateFile, the same way escapeGitTreeish already does for tree lookups.
- Lingua principale
- Go
- Stelle
- 33.6k
- Fork
- 5.2k
- Merge medio
- 2g 15h
- PR unite (30g)
- 37
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di github/github-mcp-server
-
Integer parameters equal to 2^63 pass the range check in toInt and wrap to a negative numberForse già presa @xiao115255 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
github/github-mcp-server#3489 ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
github/github-mcp-server#3475 ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
github/github-mcp-server#3450 ·
I maintainer di solito rispondono entro 4 giorni
-
request ai review
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
github/github-mcp-server#3439 ·
I maintainer di solito rispondono entro 4 giorni
-
get_job_logs with failed_only misses failed jobs after the first 30 jobs of a runForse già presa @jayhemnani9910 l’ha presa 8 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
github/github-mcp-server#3428 ·
I maintainer di solito rispondono entro 4 giorni
Tutte le issue di github/github-mcp-server
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
chaitin/agent-compose#770 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
kind/bug
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
kubernetes-sigs/vsphere-csi-driver#4351 ·
I maintainer di solito rispondono entro 1 giorno
-
component/gpu-kubelet-plugin component/helm needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
kubernetes-sigs/dra-driver-nvidia-gpu#1559 ·
I maintainer di solito rispondono entro 1 giorno
-
workflow: redundant goroutine in scheduleRetryForse già presa @moodbased l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 2 giorni