Skip to content

Fix linkcheck false positives (release-asset input, accept 200) - #39

Merged
mmcky merged 3 commits into
mainfrom
fix-linkcheck-false-positives
Jul 7, 2026
Merged

mmcky merged 3 commits into
mainfrom
fix-linkcheck-false-positives

Conversation

@mmcky

@mmcky mmcky commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What

Fixes the same link-check false-positive bug in lecture-dp that was just fixed in continuous_time_mcs (QuantEcon/continuous_time_mcs#215). lecture-dp's linkcheck uses the identical wget-mirror pattern.

The bug

The link checker mirrored the live site with wget --accept html, which fetches only HTML — none of the _static/* / _images/* assets — so lychee checked those relative links as local files and reported them all as "Cannot find file". It also used --accept 403,503, which drops 200, so every working link was flagged. On continuous_time_mcs the same config produced 522 "errors", ~all false positives; lecture-dp is exposed to the same noise.

The fix

Check links against the published HTML release asset — a permanent .tar.gz of the full site (HTML plus assets) that the publish workflow already attaches to each publish-* release (lecture-dp-html-*.tar.gz). This is the approach in QuantEcon/meta#282 (lesson 2), used by lecture-python-programming.

  • Download + extract the latest release .tar.gz into _site (replaces the wget mirror); no dependency on the live site.
  • Restore --accept 200,403,503.
  • Add --root-dir so root-relative links resolve against the site root.
  • Scan only top-level _site/*.html, so Sphinx theme partials under _static/ (raw Jinja like {{ pathto(...) }}, not real links) are skipped.

Validated the identical change on continuous_time_mcs: 522 → 6 errors, and the 6 are genuine (0 config false positives).

Related

🤖 Generated with Claude Code

lecture-dp's link checker mirrored the live site with `wget --accept html`,
which fetches only HTML — so lychee reported every local asset (_static/*,
_images/*) as "file not found" — and used `--accept 403,503`, which drops 200
so every working link was flagged.

Check the published HTML release asset instead — a permanent tarball of the
full site (HTML + assets), per QuantEcon/meta#282 lesson 2 and matching
lecture-python-programming. Restore `--accept 200,403,503`, add `--root-dir`
for root-relative links, and scan only top-level `_site/*.html` so the Sphinx
theme partials under _static/ (raw Jinja, not real links) are skipped.

Mirrors the fix in QuantEcon/continuous_time_mcs#215.

See QuantEcon/meta#282

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 7, 2026 06:19
Under `set -eo pipefail`, a transient `gh api` failure aborted the fetch step
before the empty-input guard ran, so no 'release asset missing' report was
created. Add `|| true` (and silence stderr) so the guard still fires.

Mirrors QuantEcon/continuous_time_mcs#215 (Copilot review follow-up).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the scheduled link-check workflow to avoid false positives by checking links against the published HTML release asset (which includes site assets) instead of mirroring the live site.

Changes:

  • Replace live-site wget mirroring with downloading/extracting the latest HTML release .tar.gz into _site.
  • Restore --accept 200 and add --root-dir so lychee treats working links as valid and resolves root-relative paths correctly.
  • Limit lychee’s scan scope to _site/*.html to avoid scanning non-page theme partials under _static/.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/linkcheck.yml
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.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mmcky
mmcky merged commit 0a12f79 into main Jul 7, 2026
1 check passed
@mmcky
mmcky deleted the fix-linkcheck-false-positives branch July 7, 2026 11:44
mmcky added a commit to QuantEcon/continuous_time_mcs that referenced this pull request Jul 7, 2026
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) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants