create_or_update_file writes to the wrong file when the path contains # or ?
メンテナーはふだん 4 日以内に返信
評価
調査の方向性
pkg/github/repositories.go の CreateOrUpdateFile(v1.14.0 / 71ef8266)から始める。ここでは CreateFile 呼び出しが path を未エスケープのまま渡しており、セグメントごとのエスケープの既存パターンとして escapeGitTreeish を読む。すでに正しくエスケープしている GetContents ベースの存在チェックおよび symlink チェックと比較する。完成形は、モックサーバー上で PUT /repos/{owner}/{repo}/contents/docs/C%23/intro.md が行われること、および既存の repositories テストファイルを拡張したリグレッションテストで、# および ? を含むパスが正しいファイルに書き込まれることを検証するものになる。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Go
- スター
- 33.4k
- フォーク
- 5.1k
- 平均マージ
- 3日 1時間
- マージ済み PR(30日)
- 35
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/github-mcp-server のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
github/github-mcp-server#3450 ·
メンテナーはふだん 4 日以内に返信
-
request ai review
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
github/github-mcp-server#3439 ·
メンテナーはふだん 4 日以内に返信
-
get_job_logs with failed_only misses failed jobs after the first 30 jobs of a run対応中かも @jayhemnani9910 が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
github/github-mcp-server#3428 ·
メンテナーはふだん 4 日以内に返信
-
pull_request_read drops merge_commit_sha対応中かも @thejdubb02 が 32 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
github/github-mcp-server#3235 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
Add guidance on GitHub autolinked reference formatting for AI agents再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンenhancement
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
github/github-mcp-server#3042 · コメント 2 件 ·
メンテナーはふだん 4 日以内に返信
github/github-mcp-server の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
open-telemetry/opentelemetry-go-compile-instrumentation#1467 ·
メンテナーはふだん 3 日以内に返信
-
Python 3.15 support対応中かも @amnesiaof が今日担当しました。 オープンL: python L: python:uv
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
dependabot/dependabot-core#16524 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
duplication
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
openvibely/openvibely#1443 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 60/100
canonical/service-mesh#845 ·
メンテナーはふだん 1 日以内に返信