Skip to content

MAINT: Stop busy servers from failing the docs link check - #4772

Merged
Roman Lutz (romanlutz) merged 8 commits into
microsoft:mainfrom
romanlutz:claude/build-book-failures-followup-fe3bdb
Dec 2, 2026
Merged

Roman Lutz (romanlutz) merged 8 commits into
microsoft:mainfrom
romanlutz:claude/build-book-failures-followup-fe3bdb

Conversation

@romanlutz

@romanlutz Roman Lutz (romanlutz) commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

The build-book link check failed about 15% of pull request runs between 24 and 30 Nov (68 of 444), and it also blocked docs deploys on main. Every failure I opened was github.com answering link fetches with 503 Service Unavailable, in bursts that outlast the single 30-second retry from #4478. This PR stops a busy server from failing the check while keeping real broken links fatal.

  • Tolerate only refusals and busy answers. After the retry, the check passes with a warning when every remaining error is a link that answered 403, 429 or 5xx: the server refused the checker or was busy, which says nothing about the change. A 401, a 404, a link with no response, an invalid URL, or a broken local reference still fails. The 403 case was added after genai.owasp.org answered 403 on five links for a few minutes and failed this PR's run and a main run together.
  • Check links into this repository against the checkout. build_scripts/validate_docs.py now resolves every microsoft/PyRIT/blob|tree/main/... link in doc and in pyrit docstrings against the working tree, and doc/myst.yml exempts those links from the network check. Fetching them tested main, not the change: a PR that moved a linked file passed and broke main afterwards. The validator runs in the required pre-commit check, including in the merge queue.
  • Report what the tolerance lets through. A new nightly docs-links workflow runs the same check with no tolerance, retries four times over 45 minutes, and creates or comments on one issue listing the links that are still unresolved.
  • Keep the logic in a tested script. The retry, the classification and the issue filing live in build_scripts/check_docs_links.py; both workflows call it in one line.
  • Exempt one YouTube link. The BlueHat talk link added in DOC: Add a Learn AI Red Teaming guide and a FAQ #4665 got no response from YouTube on this PR's first run and a 429 on a main run. The video is live (its oEmbed lookup returns 200), so doc/myst.yml exempts that one URL, as it already does for the other YouTube link.

Replaying the final attempt of two failed runs from 30 Nov: each had 9 errors, all 503s, so both would now pass with a warning. Four and five of those nine were links into this repository, which are no longer fetched at all.

Two things to know when reviewing:

  • A link whose server permanently answers 403 or 5xx only warns on pull requests. The nightly issue is what makes it visible.
  • The nightly workflow cannot run until it is on main, so its gh calls are covered only by unit tests with gh mocked.

🤖 Generated with Claude Code

The build-book link check failed about 15% of pull request runs because
github.com answered link fetches with 503 in bursts that outlast the single
retry.

- docs.yml: after the retry, pass with a warning when every remaining error
  is a link that answered 429 or 5xx. A 404, a link with no response, or a
  broken local reference still fails.
- validate_docs: check links to this repository's main branch against the
  checkout, so a change that moves or deletes a linked file fails before it
  merges. myst.yml exempts those links from the network check.
- docs_links.yml: nightly run with no tolerance that retries over 45 minutes
  and files an issue listing the links still unresolved.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The retry, the 429/5xx classification and the nightly issue filing were
inline shell in docs.yml and docs_links.yml. They now live in
build_scripts/check_docs_links.py, which both workflows call in one line:

- docs.yml: --tolerate-busy
- docs_links.yml: --attempts 4 --delay 900 --file-issue

Unit tests cover the classifier, the retry loop and the choice between
creating the tracking issue and commenting on it. The workflow tests now
only pin how each workflow invokes the script.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 07:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Skipping .ipynb content leaves notebook-only and saved-output links unchecked, allowing missing repository targets to pass both validation workflows.

1 open issue
What changed in this PR

This PR reduces documentation build failures caused by busy external servers while keeping broken-link checks blocking and reporting persistent failures nightly.

Changes:

  • Centralizes link checking and retries, tolerating only HTTP 429 or 5xx failures after retry.
  • Adds checkout-based validation for repository-main links and exempts them from network checks.
  • Adds a strict nightly workflow with issue reporting, unit tests, and contributor guidance.
File Description
tests/​unit/​build_scripts/​test_validate_docs.py Tests checkout-based repository link validation.
tests/​unit/​build_scripts/​test_docs_workflow.py Checks workflow commands and nightly permissions.
tests/​unit/​build_scripts/​test_docs_build_contract.py Checks repository-link network exemptions.
tests/​unit/​build_scripts/​test_check_docs_links.py Tests classification, retries, output capture, and issue reporting.
doc/​myst.yml Exempts repository-main links from network validation.
doc/​contributing/​7_notebooks.md Explains link-check tolerance and nightly reporting.
build_scripts/​validate_docs.py Checks repository-main link targets against the checkout.
build_scripts/​check_docs_links.py Implements retries, busy-response handling, and issue reporting.
.github/​workflows/​docs.yml Uses the shared checker with busy-response tolerance.
.github/​workflows/​docs_links.yml Adds strict nightly checks and issue reporting.

Review effort: Balanced

Comment thread build_scripts/validate_docs.py Resolved
YouTube gave the CI link check no response for this video on both
attempts, and answered 429 on a main run. The video is live: its oEmbed
lookup returns 200 with the matching title. Exempt only this URL, as is
already done for the other YouTube link in the docs.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The docs site is built from the .ipynb files, which can differ from their
paired .py and carry links in saved outputs. Those links are exempt from the
network check, so validate_docs now reads notebooks too.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review completed. No blocking concerns remain. This review records source coverage; merging is handled separately.

Comment thread build_scripts/check_docs_links.py Resolved
Comment thread build_scripts/check_docs_links.py Resolved
Comment thread .github/workflows/docs_links.yml Resolved
Comment thread build_scripts/check_docs_links.py Resolved

@hannahwestra25 hannahwestra25 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks :)

- Stream the build output line by line instead of printing it after the
  build exits, so a hung or slow attempt still leaves a log.
- Leave gh's stderr uncaptured, so a failed issue call shows its reason.
- Look up the tracking issue only among issues filed by github-actions.
- Pin the MyST theme in the nightly workflow, as docs.yml does.
  pin_docs_theme takes --slug to read the template from docs-versions.yml.
- Make the parser test fixture include the line MyST prints when it finds
  an error, so loosening the summary anchor fails the tests.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The child's deadline only guards against a hang. A fixed 30 seconds could
fail the test on a busy worker even though the output was streamed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Dec 2, 2026
genai.owasp.org answered 403 on five links for a few minutes, which failed
this PR's run and a main run at the same time, then recovered. A 403 says
the server refused the checker, not that the page is gone; every 403
exemption already in doc/myst.yml is bot protection.

The PR check now passes with a warning when every remaining error is a
link that answered 403, 429 or 5xx. The option is renamed from
--tolerate-busy to --tolerate-unverified to match. A 401, a 404, a link
with no response and a broken local reference still fail, and the nightly
run still reports links that stay forbidden.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Merged via the queue into microsoft:main with commit 98d1dd6 Dec 2, 2026
1 check passed
@romanlutz
Roman Lutz (romanlutz) deleted the claude/build-book-failures-followup-fe3bdb branch December 2, 2026 07:47
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.

4 participants