-
[OPIK-7135] [GHA] fix: dedup docs-preview broken-link report by URL (#7263)
发布于
2026-06-30 10:32:13 +00:00 - [OPIK-7135] [GHA] fix: dedup + de-flake docs-preview broken-link report
The Docs - Preview link workflow built one comment line per
(parent page, broken url) pair with no deduplication. A broken page
linked from the API sidebar (hundreds of pages) plus transiently-failing
reference pages turned a handful of unique broken URLs into thousands of
report lines (observed ~937KB), overflowing GitHub's 65,536-char comment
limit and making the check flaky.Changes:
- Dedup broken links by URL with group_by so each appears once.
- Treat linkinator status 0 (crawl timeout/abort) separately: it is not
an HTTP error. Re-verify each unique status-0 URL with a direct request
and keep it only if genuinely unreachable — healthy-but-slow pages that
timed out mid-crawl no longer show as false-positive broken links. - Guard against a crashed crawl: linkinator can die mid-recurse on an
unhandled stream error (e.g. ECONNRESET), leaving missing/truncated
output. Validate the JSON; if unusable, post a "did not complete" comment
and fail the check so the red status forces a re-run. - Fail the check (red) whenever broken links remain or the crawl did not
complete: post the comment with the details first (always()), then fail
the job so the check blocks until the links are fixed / re-run. - Strip the ephemeral preview host from the "on page" pointer so it shows
the stable relative doc path (greppable to find the source .mdx). - Raise linkinator --concurrency to 500: the preview CDN serves bursts
without rate-limiting (no 429s observed), and the recurse over thousands
of pages otherwise brushes the job's 15-minute timeout. - Trigger the workflow when its own file changes so edits are exercised
on the PR.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
- fix(ci): scope status-0 recheck curl to the preview origin (SSRF)
The status-0 re-verification loop curled URLs taken from the crawl of
PR-authored docs. Restrict the recheck to the preview origin so a
PR-authored link can't direct curl at an arbitrary internal/external
endpoint; off-origin status-0 URLs are reported as crawled without a
recheck. The false positives the recheck targets are preview-host pages
that timed out mid-crawl, so this is also more correct.Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
- refactor(ci): dedupe broken-link reporting helper, trim comments
Factor the repeated parent-lookup + append into a single report_timeout
helper (was inlined 3×), collapse the two status-0 branches into one
case, and cut comments down to the non-obvious why.Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Co-authored-by: Claude Opus 4.8 (1M context) noreply@anthropic.com
下载附件