framework-tooling: codex review wrappers (PR mode) review the wrong branch + auto-post to PR #795
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
codex-code-review.sh/codex-security-review.shin PR mode (-n <PR>) can review the wrongcode on Gitea and then auto-post the resulting (spurious) findings to the PR.
Root cause
tools/codex/common.sh→build_diff_context(), gitea PR branch:It resolves only the PR base branch and diffs
${pr_base}...HEAD. It never fetches/checks out thePR head. In a fresh clone whose
HEADis the default branch,pr_base = mainandHEAD = main, sogit diff main...HEADis empty. Given an empty diff, the Codex agent free-lances and reviews anunrelated branch. Because
-nauto-enables--post-to-pr(seecodex-code-review.sh:57–58), thespurious verdict/finding is then posted to the PR.
Impact (integrity)
A bad verdict can block a good PR or pollute the review record. Observed live: a review invoked
as
-n 793diffedfeat/758-v1-v2-migratorinstead of PR #793's head, then auto-posted afleet/roster-v2.tsfinding onto #793 (whose diff is two unrelatedclaudex-proxy.tsfiles). Thefinding had to be manually retracted and the review re-run correctly.
Fix
refs/pull/<n>/head) before diffing.git diff <base>...<pr_head>— not...HEAD.nothing; never post a review derived from an empty/degenerate diff.
HEAD ≠ PR headmust review the PR'sactual changed files (or fail loudly), never a different branch.
Verified workaround (until fixed)
git checkout <pr-head-branch>in the clone, then run with-b <base>(not-n), inspect thediff matches the PR's changed files, and post the review manually.