Repository navigation
CI: do not authenticate an unused robot token in the Codex code review - #115232
Conversation
The Code Review job died on `gh auth login` for 10 pull requests in the 24 h to
2026-08-17, losing the automated review for those heads:
ERROR: Codex review failed after 3 attempts: CalledProcessError:
Command '['gh', 'auth', 'login', '--with-token']' returned non-zero exit status 1.
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113059&sha=83188f6442a4f2d7e4376efe54c2bf3bad32dd50&name_0=PR&name_1=Code%20Review
https://s3.amazonaws.com/clickhouse-test-reports/PRs/113059/83188f6442a4f2d7e4376efe54c2bf3bad32dd50/code_review/job.log
ClickHouse#113059
_run_codex_once authenticated a robot token before every attempt, under
check=True, so any rejection raised before the agent started. The Codex backend
does not use that token. The job sets enable_gh_auth=True, so the runner mints a
GitHub App token into the ambient gh config before the script runs, and the
prompt has the agent prefix every gh call with GH_PREFIX = "env -u
GH_CONFIG_DIR", discarding the scoped robot directory. Over all 25 job logs that
reached the agent, 246 of 246 executed gh calls unset it and none used the robot
directory, and every HTTP 401 in those logs belongs to the robot login rather
than to an agent call. So that login could only ever fail the job.
/ci/robot-ch-test-poll-copilot has answered HTTP 401: Bad credentials on 27 of 27
observed attempts, with no success, since 2026-08-03, while
/ci/robot-ch-test-poll-1-copilot never returned a 401: one dead credential, not a
window-wide outage. Two robots over three attempts rotate as [X, Y, X], so the
healthy robot gets one attempt of three when the shuffle puts the dead one first,
and a single transient GraphQL 503 on that attempt then fails the job. The
rotation had been silently absorbing a permanently broken credential for two
weeks.
Remove the login and its temporary GH_CONFIG_DIR from the Codex attempt, so it
runs on the app identity it was already using and the retry budget is spent on
agent failures. _run_copilot_once keeps its login: the Copilot CLI authenticates
to GitHub with that token directly. Rotating the dead token remains an
operational matter, which the Codex path no longer depends on.
The new test file covers both: five cases fail on the previous code with the
error above, and two pin behaviour that must not change, each verified by
mutating the code it pins. One of those pins is the enable_gh_auth flag the
Codex path now depends on, which lives in ci/defs/job_configs.py rather than in
the job, so nothing else in the suite would notice its removal.
Internal second-model reviewAn independent cold review plus a second model reviewed this change before it was opened. Verdicts
Verification behind the change: the premise that the Codex backend never uses the robot token was |
Pre-PR validation gate (click to expand)
|
|
Workflow [PR], commit [b12c594] Summary: ✅ AI ReviewSummaryThis PR removes the unused robot-token Final Verdict✅ No blocking or major issues found. |
|
cc @Algunenano @maxknv, could you review this? The Codex backend ran |
b969510
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Related: #113059
The
Code Reviewjob died ongh auth loginfor 10 pull requests in the 24 h to2026-08-17, losing the automated review for those heads. A fork PR cannot re-run it,
so recovery needs a fresh push.
_run_codex_onceauthenticated a robot token before every attempt, undercheck=True, but the Codex backend never uses it:enable_gh_auth=Truehas therunner authenticate the app up front, and the prompt runs every agent
ghcall withGH_CONFIG_DIRunset. Across the 25 job logs that reached the agent,246 of 246 executed
ghcalls unset it and none used the scoped robot directory, sothat login could only fail the job. In those same logs
/ci/robot-ch-test-poll-copilotansweredHTTP 401: Bad credentialson 27 of 27attempts, the oldest on 2026-08-03, and
/ci/robot-ch-test-poll-1-copilotnever did.Two robots
over three attempts rotate as
[X, Y, X], so the healthy one gets a single attemptwhen the shuffle puts the dead one first, and one transient GraphQL 503 there fails
the job.
This removes that login and its temporary
GH_CONFIG_DIRfrom the Codex attempt, soit runs on the app identity it already used and retries serve agent failures.
_run_copilot_oncekeeps its login, which the Copilot CLI does use.New
ci/tests/test_copilot_review_codex_auth.py: 5 tests fail on the current codewith the error above and pass here; the 2 pinning unchanged behaviour were verified
by mutating the code they pin. No secret, process or sleep involved.
Out of scope:
/ci/robot-ch-test-poll-copilotstill needs rotating operationally(
--copilotwould still need it); and 8 further failures that window are a separatedefect,
gh api -X PATCHonissues/comments/<id>returning 503 after its retries.Workflow [PR]
Sync PR [sync-upstream/pr/115232]
Version info
26.9.1.36(included in26.9and later)