Repository navigation
ci: retry Copilot Code Review on transient gh API failures - #104227
alexey-milovidov merged 1 commit into
Conversation
The Code Review job's Copilot CLI subprocess occasionally hits transient
GitHub authorization errors mid-run, e.g.
[10:08:14] Authorization error, you may need to run /login (Request ID: F924:13DD23:...)
[10:08:14] ERROR: command failed after 1/1 attempt(s), exit code: 1
[10:08:14] ERROR: Copilot did not write ./ci/tmp/copilot_review.md
RuntimeError: Copilot did not write ./ci/tmp/copilot_review.md
(seen on PR ClickHouse#104204 attempt 2 of run 25428876194; attempt 3 of the same
run completed cleanly.) Without retries, a single transient blip from the
GitHub auth path inside Copilot is enough to mark "Code Review" as `FAIL`
and post `Mergeable Check: Failed: Code Review, Dropped: 71`.
Two fixes:
1. `ci/jobs/copilot_review_job.py`: wrap the gh-auth + copilot subprocess
sequence in a 3-attempt retry loop with exponential backoff. Each
attempt re-fetches the secret, re-runs `gh auth login` against a fresh
`GH_CONFIG_DIR`, and re-invokes Copilot. An attempt counts as success
only if the subprocess exits 0 AND `REVIEW_FILE` is written non-empty
— auth failures inside Copilot don't surface as exceptions, only as
exit code != 0 and a missing review file.
2. `ci/praktika/gh.py`: add `GH.get_output_with_retries(cmd)` helper that
mirrors `do_command_with_retries` but returns stdout. Use it for every
GitHub-API read that previously called bare `Shell.get_output(cmd)`:
`post_pr_comment`, `post_fresh_comment`, `post_updateable_comment`,
`get_pr_contributors`, `get_pr_labels`, `get_pr_title_body_labels`,
`get_pr_label_assigner`, `get_pr_diff`, `pr_has_conflicts`. These
would previously return `""` on transient `gh` failures and either
propagate as `json.loads('')` errors or silently misclassify the PR
(e.g. miss an existing comment and post a duplicate). Same
non-retryable error classes as `do_command_with_retries`
(`Validation Failed`, `Bad credentials`, `Resource not accessible`).
Also harden `post_updateable_comment` against malformed JSON: catch
`json.JSONDecodeError` and treat it as "no existing comments" rather
than crashing the caller.
Reported-by: alexey-milovidov <ClickHouse#104204 (comment)>
Session-ID: cron:clickhouse-ci-task-worker:20260506-131500
Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Pre-PR validation gate self-check (per worker
Session-ID: cron:clickhouse-ci-task-worker:20260506-131500 |
|
cc @alexey-milovidov @maxknv @leshikus — could you review? Fixes the transient "Code Review" failure described in the PR body. Two layers of retry: (1) the Copilot subprocess gets re-tried 3 times with re-auth, (2) every |
|
Workflow [PR], commit [c9474d6] Summary: ✅ AI ReviewSummaryThis PR improves resiliency of the Copilot review job by adding retries around Findings
ClickHouse Rules
Performance & Safety
Final VerdictStatus: Minimum required action:
|
On PR #104204, the
"Code Review" check failed because the Copilot CLI hit a transient
GitHub authorization error mid-run, after ~1m 9s of work:
Failed job: https://github.com/ClickHouse/ClickHouse/actions/runs/25428876194/job/74589889048
(workflow attempt 2 / Code Review attempt 1 of run
25428876194).A 3rd workflow attempt re-ran Code Review at 11:03:54Z and finished cleanly,
which confirmed the failure was a transient blip — but by that point the
Mergeable Checkstatus had already been set tofailure("Failed: CodeReview, Dropped: 71") at 10:22:35Z when Finish Workflow saw the failed run.
Per @alexey-milovidov's directive (comment):
This PR adds two layers of retry:
ci/jobs/copilot_review_job.py— wrap the gh-auth + copilotsubprocess sequence in a 3-attempt retry loop with exponential
backoff. Each attempt re-fetches the secret, re-runs
gh auth loginagainst a fresh
GH_CONFIG_DIR, and re-invokes Copilot. An attemptcounts as success only if the subprocess exits 0 AND
REVIEW_FILEiswritten non-empty — auth failures inside Copilot don't surface as
exceptions, only as exit code ≠ 0 and a missing review file.
ci/praktika/gh.py— addGH.get_output_with_retries(cmd), theread-style counterpart of
do_command_with_retries. Replace bareShell.get_output(cmd)with the new helper for everyGitHub-API read in
gh.py:post_pr_commentpost_fresh_commentpost_updateable_commentget_pr_contributorsget_pr_labelsget_pr_title_body_labelsget_pr_label_assignerget_pr_diffpr_has_conflictsThese would previously return
""on a transientghfailure andeither propagate as
json.loads('')crashes or silently misclassifythe PR (e.g. miss an existing comment and post a duplicate). Same
non-retryable error classes as
do_command_with_retries(
Validation Failed,Bad credentials,Resource not accessible).Also harden
post_updateable_commentagainst malformed JSON: catchjson.JSONDecodeErrorand treat it as "no existing comments" ratherthan crashing the caller.
Local sanity check:
CI Report (failed run that motivated this fix):
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104204&sha=4e0497e7d58595bbab725d3f27d16c9303577b0f&name_0=PR&name_1=Code%20Review
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not applicable — CI fix.
Documentation entry for user-facing changes
Version info
26.5.1.349