Repository navigation
Download binlog artifacts to a file so curl retries cannot corrupt them - #17309
Merged
YuliiaKovalova merged 4 commits intoAug 12, 2026
Merged
Conversation
Review follow-up. Streaming the download through a pipe made every curl
retry append rather than restart: a transient 503 whose error body was
written before the retry produced <error page><zip> on disk and curl
still exited 0, so the corruption was undetectable by any exit-status
check and surfaced only as an unreadable archive. That dropped the leg
and, with it, the whole analysis - the reported symptom.
Reproduced against a local server that returns 503 then 200: piped, the
file was payload+64 bytes with curl_rc=0 and unzip reported 'extra bytes
at beginning'; writing to a seekable file with -o yields the exact
payload. --fail additionally keeps HTTP error bodies off disk. The
head -c cap is preserved via ulimit -f, with SIGXFSZ ignored so the cap
is hit as an ordinary write error instead of a signal death that logs
'File size limit exceeded (core dumped)'.
Also fixes two latent defects found while verifying:
- awk '{print }' ran over every line of unzip -Zt output, and Info-ZIP
writes warnings to stdout, so UNCOMP could be multi-line; grep -q then
matched on any line and let it through. Uses awk 'END{print }'.
- The added 'shell: bash' turns on -o pipefail, so the export step's
printf | head -1 became a SIGPIPE-abort risk; replaced with a
parameter expansion.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: c5dc4518-6af1-496b-bbbb-f878b9a67ac6
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the Build Failure Analysis GitHub Actions workflows’ artifact download path so curl --retry cannot silently corrupt downloaded binlog zip artifacts, improving reliability of multi-leg binlog collection and downstream analysis.
Changes:
- Switches artifact downloads from
curl | headpiping tocurl -owith a filesystem-enforced size cap (ulimit -f) and--failto avoid writing HTTP error bodies. - Fixes
unzip -Ztparsing to use only the final summary line to prevent warning output from bypassing numeric guards. - Avoids a
pipefail/SIGPIPE failure mode when selecting the first binlog path by using parameter expansion instead ofprintf | head.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| .github/workflows/build-failure-analysis.md | Updates binlog artifact download to be retry-safe and improves robustness of zip size verification and list handling. |
| .github/workflows/build-failure-analysis.lock.yml | Regenerates the compiled workflow lock to reflect the updated template logic. |
| .github/workflows/build-failure-analysis-command.md | Applies the same retry-safe download + parsing fixes to the command-triggered workflow. |
| .github/workflows/build-failure-analysis-command.lock.yml | Regenerates the compiled workflow lock for the command-triggered workflow. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Review feedback suggested the divisor should be 512 because POSIX defines the standalone ulimit utility in 512-byte blocks. That does not apply here: the step runs under 'shell: bash', and bash's builtin uses 1024-byte blocks. Measured on bash 5.2.21, 'ulimit -f 1' caps a file at 1024 bytes and 'ulimit -f 2' at 2048, so the /1024 divisor gives the intended 500 MB. Recording the measurement inline so the divisor is not mistaken for a bug again. Comment-only change; the cap itself is unchanged. Co-authored-by: Copilot <[email protected]> Copilot-Session: c5dc4518-6af1-496b-bbbb-f878b9a67ac6
Review feedback flagged the /1024 divisor on the grounds that ulimit -f counts 512-byte blocks. bash's builtin actually uses 1024-byte blocks, but relying on either reading is fragile, so remove the dependency instead of arguing the measurement. Dividing by 512 gives a cap of exactly MAX_ZIP_BYTES under the 512-byte reading and twice that under the 1024-byte reading. Both are at least MAX_ZIP_BYTES, so a valid artifact is never truncated, and the authoritative 'ZIP_BYTES -ge MAX_ZIP_BYTES' guard rejects an oversized one wherever the kernel cap lands. ulimit stays purely a disk backstop for responses that declare no Content-Length. Verified against a length-less local server under both readings: a 900 KB artifact is accepted and 1.5 MB and 5 MB artifacts are skipped by the cap guard, with identical outcomes either way. Co-authored-by: Copilot <[email protected]> Copilot-Session: c5dc4518-6af1-496b-bbbb-f878b9a67ac6
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
.github/workflows/build-failure-analysis.md:365
- The
ZIP_BYTES -ge MAX_ZIP_BYTESguard will also skip a valid archive whose compressed size is exactlyMAX_ZIP_BYTES(e.g., a 500MB zip), even whencurlcompleted successfully. The-gecomparison only needs to treat the equality case as “hit the cap” whencurlreported a write error (e.g., rc=23 from theulimit -fbackstop).
if [ "${ZIP_BYTES}" -ge "${MAX_ZIP_BYTES}" ]; then
echo "::warning::Skipping ${name}: download reached the ${MAX_ZIP_BYTES}-byte cap."; continue
fi
.github/workflows/build-failure-analysis-command.md:423
- The
ZIP_BYTES -ge MAX_ZIP_BYTESguard will skip a valid archive whose compressed size is exactlyMAX_ZIP_BYTESeven whencurlsucceeded. Equality only needs to be treated as “hit the cap” whencurlreported a write error (e.g., rc=23 from theulimit -fbackstop).
if [ "${ZIP_BYTES}" -ge "${MAX_ZIP_BYTES}" ]; then
echo "::warning::Skipping ${name}: download reached the ${MAX_ZIP_BYTES}-byte cap."; continue
fi
The rationale comments had grown longer than the code they explain, with the download block carrying 27 lines of comment for 5 lines of shell. Trim each block to the non-obvious reason it exists and drop the narrative, roughly halving the comment volume (152 lines -> 84). No behaviour change: the only non-comment difference in the recompiled locks is gh-aw's regenerated heredoc delimiters. Co-authored-by: Copilot <[email protected]> Copilot-Session: c5dc4518-6af1-496b-bbbb-f878b9a67ac6
JanKrivanek
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #17301, which merged just before this last fix landed on the branch.
A second review pass found a defect that explains the dropped binlog legs better than the fix in #17301 did.
Root cause
The download was
curl --retry 3 ... | head -c CAP > file. Stdout is not seekable, so curl cannot rewind when it retries. When the server answers with a transient 5xx, curl writes the error body, then retries and appends the real archive. The file ends up as<error page><zip>— and curl exits 0, so no exit-status check can detect it.unzipthen reportsextra bytes at beginning, the leg is skipped, and the all-legs guard aborts the whole analysis.That is exactly the
Skipping Logs_Build_...followed byOnly 1 of 2 Logs_Build_* legs produced a usable binlogpair seen in run 30921596534.Reproduced against a local server that returns 503 once and then 200:
curl_rc=0,unzip -Ztrc=1extra bytes at beginning-o: byte-identical to the payload--failadditionally keeps HTTP error bodies off disk in the first place.The
head -ccap is preserved asulimit -f(1 KiB units), which the kernel enforces even when the response declares noContent-Length.SIGXFSZis ignored so hitting the cap surfaces as an ordinary write error (curl 23) instead of a signal death that printsFile size limit exceeded (core dumped)into the log. The size guard uses-gebecause truncation lands exactly on the cap.Two latent defects found while verifying
awk '{print $3}'ran over every line ofunzip -Ztoutput, and Info-ZIP writes recoverable-archive warnings to stdout.UNCOMPcould therefore be multi-line, andgrep -qmatches if any line matches — so a corrupt archive could pass the numeric check. Nowawk 'END{print $3}'.shell: bashadded in Fix build-failure-analysis agent: 403 auth failure and lost binlog legs #17301 is not a no-op: GitHub's default isbash -e {0}, but an explicitshell: bashisbash --noprofile --norc -eo pipefail {0}. The fetch step clearspipefailexplicitly, but "Export agent context" did not, leavingprintf | head -1able to abort the step on SIGPIPE. Replaced with${LIST%%$'\n'*}.Verification
curl_rc=18, skipped with an accurate messagecurl_rc=23, no misleading log line--failwrites 0 bytes → skippeddnceng-publicbuilds 1547565 and 1547234: both stage 2/2 legs through traversal scan, extraction and stagingBoth lock files were recompiled with the pinned gh-aw v0.77.5; the diff is only these four files.
One deliberate non-change: all three
unzipinvocations still fail closed on rc≠0, so an archive that is merely warning-producing but still extractable will drop its leg. That is the existing posture for untrusted PR archives and I did not want to loosen it, particularly now that the thing generating such archives is gone.