From 0e46efd91bfa61a18a910eeeb82cd80158e69cac Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Tue, 7 Jul 2026 21:42:15 +1000 Subject: [PATCH] Harden release-asset extract against partial downloads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A failed or truncated `curl | tar` was swallowed by `|| true`, potentially leaving a partial _site tree where count > 0 — so lychee would run against an incomplete site and re-introduce 'file not found' false positives. Use `curl -f` and an `if !` guard that clears _site on failure, so a bad download is treated as 'no usable asset' and reported via the guard. Ports the hardening from QuantEcon/lecture-dp#39 (Copilot review follow-up). Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/linkcheck.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linkcheck.yml b/.github/workflows/linkcheck.yml index 1371064..194f69b 100644 --- a/.github/workflows/linkcheck.yml +++ b/.github/workflows/linkcheck.yml @@ -29,7 +29,14 @@ jobs: --jq '.assets[] | select(.name | endswith(".tar.gz")) | .browser_download_url' 2>/dev/null | head -1 || true) mkdir -p _site if [ -n "$asset_url" ]; then - curl -sSL "$asset_url" | tar -xz -C _site || true + # `curl -f` fails on HTTP errors; an `if !` guard catches a failed + # or partial download/extract and discards the incomplete tree, so + # lychee never runs against a half-extracted site (which would + # reintroduce "file not found" false positives). + if ! curl -fsSL "$asset_url" | tar -xz -C _site; then + echo "::warning::could not download/extract $asset_url — treating as no usable asset" + rm -rf _site && mkdir -p _site + fi fi count=$(find _site -name '*.html' | wc -l | tr -d ' ') echo "Extracted $count HTML file(s) from the latest release asset"