codex icon indicating copy to clipboard operation
codex copied to clipboard

gitDiffToRemote fails on an unpushed topic branch when the remote default branch contains a slash

Open dovvnloading opened this issue 2 weeks ago • 1 comments

The app-server RPC cannot generate a patch for a local topic branch based on origin/release/stable. It returns JSON-RPC error -32600 even though the base commit is available locally. The same sequence with the default branch named stable returns the correct SHA and patch.

Environment Official Codex CLI 0.169.0, Linux x86_64, Git 2.52.0. Reproduced with two local Git repositories and no network or model calls.

Steps to reproduce

d=$(mktemp -d)
git init -q -b release/stable "$d/upstream"
echo base > "$d/upstream/base.txt"
git -C "$d/upstream" add base.txt
git -C "$d/upstream" -c user.name=Repro -c [email protected] commit -qm base
git clone -q "$d/upstream" "$d/work"
git -C "$d/work" switch -qc topic
echo change > "$d/work/topic.txt"
git -C "$d/work" add topic.txt
git -C "$d/work" -c user.name=Repro -c [email protected] commit -qm topic
git -C "$d/work" symbolic-ref refs/remotes/origin/HEAD
git -C "$d/work" diff --stat origin/release/stable

Start codex app-server --stdio. Send initialize with {"clientInfo":{"name":"repro","version":"1"},"capabilities":{}}, then the initialized notification. Call gitDiffToRemote with {"cwd":"<absolute path to work>"}.

Observed Git prints refs/remotes/origin/release/stable and a one-line insertion in topic.txt. Codex returns -32600: failed to compute git diff to remote for cwd: ….

Expected Return the SHA of origin/release/stable and a diff adding topic.txt, just as the single-component default-branch control does.

Suggested fix The Rust default-branch resolver takes everything after the final slash, turning release/stable into stable. Strip the exact refs/remotes/<remote>/ prefix to keep the full branch name. Related issue #30940 demonstrates a similar truncation in the Desktop JavaScript branch picker. This reproduction exercises the Rust RPC directly. Rust resolver

dovvnloading avatar Nov 14 '26 01:11 dovvnloading

I added a focused codex-git-utils regression for the slash-containing remote default branch reported here. In two local Git repositories, stable passed, while release/stable failed on unmodified pinned source because get_default_branch returned stable. The reporter's official 0.169.0 RPC reproduction remains the release evidence.

I tested the proposed exact-prefix fix: remove refs/remotes/{remote}/ from the symbolic-ref output while preserving the remaining branch path. On the pinned checkout, the regression then passed with the expected remote SHA and topic.txt patch. All 50 codex-git-utils library tests, formatting, and diff checks passed in a network-disabled Linux container.

I also ported the test and candidate to fresh main 44834c5; formatting and diff checks pass there. The offline current-main Cargo test stopped before compilation because its cache lacks etherparse, so I cannot claim a current-main test pass. I have not rerun the app-server RPC or checked other platforms. I can share the regression and patch if useful.

TheOutlandsDev avatar Nov 17 '26 03:11 TheOutlandsDev