Repository navigation
Build profile diff: report why a gh api call failed - #115201
alexey-milovidov merged 4 commits into
Conversation
The job's only record of a failed commits-walk fetch was the gh argv: CalledProcessError: Command '['gh', 'api', 'repos/ClickHouse/ClickHouse/ commits?sha=a3f55f0418cdd06... Two places discarded the reason. _list_commits_page ran subprocess.run with check=True, and CalledProcessError.__str__ renders only argv, so the captured stderr and stdout - the fields carrying the HTTP status - were never read (measured against a real 404: e.stderr held 'gh: Not Found (HTTP 404)' and e.stdout the full JSON body). The resulting message then passed through md_code, a table-cell name formatter whose MAX_NAME_LEN is 100, which head-truncates and so dropped the tail as well. A 404, a 403 rate limit and a 5xx therefore rendered the same 102-character string in the public pull request comment, and since the walk performs up to EXTEND_MAX_PAGES fetches the message did not say which anchor or page had failed. Report the failure instead: exit code and endpoint first, then stderr and stdout each capped at 300 characters with an explicit elision marker, mirroring the field order and cap that GH.get_output_with_retries already uses. Catch TimeoutExpired in the same place so a stalled request says it timed out. The timeout is kept: gh self-bounds connect (30 s) and TLS handshake (10 s) but not a stalled response body, measured at 240 s unbounded, so routing this through the shared praktika helper - which passes no timeout - would have regressed a bounded call site to an unbounded one. Add md_message beside md_code for the comment path, bounded head+tail so the end of a message survives. md_code and MAX_NAME_LEN are untouched, so the name callers keep their behaviour. The bound matters beyond gh: a cluster query failure reaches the same handler carrying its whole inlined SQL, which for the extended master chain measures 54952 characters against GitHub's 65536-character comment body limit. The underlying gh api failure is not addressed here. It is environmental and unreproducible outside CI - the byte-identical call succeeds 25 of 25 by hand, failures interleave with successes through the day, and carriers are both fork and non-fork pull requests. The point of this change is that the next occurrence records its own HTTP status. No committed test: ci/tests/test_build_profile_diff_job.py was removed in PR ClickHouse#114675 and .claude/CLAUDE.md asks for a throwaway test for CI scripts. Verified with a 30-assertion throwaway harness plus three mutation arms, each reverting one hunk and reddening named assertions.
Internal second-model review (click to expand)Two independent passes over this diff: a cold read of the resulting code, then a second-model
Also verified independently rather than taken from the change: Session id: cron:clickhouse-review-slot-10:20260817-192500 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20260817-183500 |
|
Workflow [PR], commit [869bfdd] Summary: ✅ AI ReviewSummaryThis PR changes Final Verdict✅ No findings. |
|
cc @alexey-milovidov @leshikus, could you review this? |
…iff-gh-api-error-reporting
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units14 translation units recompiled, 9 s compile time in total, 12 of them have a recent master baseline. |
The build-profile-diff comment renders a failing exception inline in a code span. A CommonMark span closes at the first backtick run whose length equals the opener, and a backslash is not an escape inside a span, so a message carrying backticks of its own escaped the span and the remainder of the diagnostic rendered as prose. This file raises exactly such a message: "No `master_track_commits_sha` metadata - cannot anchor the baseline on the PR's master parent". Measured through GitHub's /markdown endpoint in gfm mode, the whole message now lands in a single <code> element; before, it split into three spans with the setting name leaking out as prose. The defect predates this change (the same message under md_code's 100-char cap keeps both backticks and breaks identically), but md_message is the helper that promises to carry free-form text, so that is where it belongs. The fence is the shortest backtick run absent from the text. A message whose first or last character is a backtick additionally gets a space, which the renderer strips back off: without it the run merges with the fence into a longer run and the span never opens at all. Reported by clickhouse-gh[bot] on the pull request.
…ter walk `_list_commits_page` ran one `gh api repos/ClickHouse/ClickHouse/commits` call and raised on the first non-zero exit or timeout, and the per-TU master first-parent walk makes ~20 such calls per job. GitHub fails single requests (HTTP 503 and 504, a body cut short so `--jq` reports `unexpected end of JSON input`, a stalled body) while the requests around them succeed, so one blip errored the whole check: 9 jobs on 9 PRs between 2026-10-03 and 2026-10-14, the failing anchors 11-15 days deep in walks whose earlier fetches had just succeeded, and the same commits passing on other runs. Retry the listing up to 3 times (after 5 s, then 10 s), keeping the 120 s per-call timeout. A timeout, an HTTP 5xx or 429, or a failure whose stderr names no HTTP status is retried; any other 4xx (unknown sha, permissions) fails at once, since `gh` reports an HTTP error as `gh: <message> (HTTP <status>)`. After the last attempt the error propagates as before, so the walk stays fail-close as the `extend_master_shas` docstring requires. The praktika `GH` helpers retry but pass no subprocess timeout, which ClickHouse#115201 kept on this call site on purpose. CI reports: - https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=124959&sha=1d61eebf3fe5ed809d4811ea947169074a3e1712&name_0=PR&name_1=Build%20profile%20diff (ClickHouse#124959) - https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125328&sha=ab772cc3b97c2e6777f2ef60723bcbeb5a5f29e3&name_0=PR&name_1=Build%20profile%20diff (ClickHouse#125328) - https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=122585&sha=bf8b2d2470663e1b5703c2014b7887fe2d5dd239&name_0=PR&name_1=Build%20profile%20diff (ClickHouse#122585) - https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119371&sha=88edddd16dcd4250ac56e1642f964a03763097f4&name_0=PR&name_1=Build%20profile%20diff (ClickHouse#119371) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #115061
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Build profile difffailed on #115061 with a message naming only theghargv(report,
job log):
Two things discarded the reason.
_list_commits_pageusedcheck=True, andCalledProcessError.__str__renders only argv, so the capturedstderr/stdoutcarrying the HTTPstatus were never read. The message then went through
md_code, a table-cell name formatter(
MAX_NAME_LEN = 100), cutting the tail. So 404, 403 and 5xx produced the same 102-characterstring, and the walk makes up to 60 calls without naming which failed.
Report it instead: exit code and endpoint first, then
stderrandstdouteach capped at 300characters with an elision marker, in the field order
GH.get_output_with_retriesuses.TimeoutExpiredis caught in the same place.timeout=120is kept deliberately -ghboundsconnect and TLS handshake but not a stalled response body (measured 240 s unbounded), so the shared
praktika helper, which passes no timeout, would unbound a bounded call site.
md_messageis added besidemd_codefor the comment path, bounded head+tail so the end of amessage survives. Its fence is also longer than any backtick run in the text: this file's
own
`master_track_commits_sha`fail-close message otherwise closes the span early and leaksinto prose, as it already does under
md_code.md_codeandMAX_NAME_LENare untouched: its 17name callers are byte-identical. The bound matters beyond
gh: a cluster query failure reaches thesame handler carrying its whole inlined SQL, 54952 characters against GitHub's 65536 limit.
The
gh apifailure itself is environmental and out of scope: the same call succeeds 25/25 byhand.
Validated with throwaway harnesses plus mutation arms reverting each hunk; every rendering verdict
comes from GitHub's own
/markdownendpoint.ci/tests/: 711passed, its 2 failures pre-existing on master. No committed test, per
.claude/CLAUDE.md:ci/tests/test_build_profile_diff_job.pywas removed in #114675.Workflow [PR]
Sync PR [sync-upstream/pr/115201]