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

Open Beginner friendly
#61,441 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
git, rust
Domain
devtools

Research direction

The bug is in the default-branch resolver in codex-rs/git-utils/src/info.rs (around lines 456-477), which keeps only the text after the last slash of refs/remotes/origin/release/stable. Start there, strip the exact refs/remotes/<remote>/ prefix instead, and confirm the branch name is preserved. Done when the reproduction in the issue returns the SHA of origin/release/stable and a diff adding topic.txt, and the single-component control still passes.

Written by the indexing model from the issue text.

Description

app-server bug CLI

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

Dominant language
Rust
Stars
135k
Forks
21.4k
Avg merge
1m
Merged PRs (30d)
997

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openai/codex

All issues in openai/codex

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.