Skip to content

Harden markdown link checker against transient network failures#27715

Draft
TravisEz13 with Copilot wants to merge 2 commits into
masterfrom
copilot/harden-markdown-link-verification
Draft

Harden markdown link checker against transient network failures#27715
TravisEz13 with Copilot wants to merge 2 commits into
masterfrom
copilot/harden-markdown-link-verification

Conversation

Copilot AI commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

CI link-check jobs were failing on valid URLs (aka.ms, microsoft.com) with "An error occurred while sending the request." — transport-level exceptions that Invoke-WebRequest's built-in -MaximumRetryCount does not retry (it only retries HTTP 5xx).

Changes

Verify-MarkdownLinks.ps1 — core fix

  • Replace Invoke-WebRequest built-in retry with a manual loop that catches transport exceptions (timeouts, TLS, DNS failures)
  • Each attempt: HEAD first → fall back to GET if HEAD throws or returns 404/405
  • Exponential backoff between attempts: starts at 2s, doubles, capped at 15s
  • Default attempts: 4 total (MaximumRetryCount=3); default timeout: 20s
  • Add -MaximumRedirection 10 to all requests
  • Log attempt count in pass/fail/ignore lines

action.yml — update defaults to match (timeout-sec: 20, maximum-retry-count: 3)

verify-markdown-links.yml — pass updated values explicitly

Retry semantics

Outcome Behavior
Any attempt returns 2xx/3xx Pass immediately
All attempts exhausted Fail — broken link is real
401/403/429 status Skip (unchanged)
# Before: single attempt, transport error → immediate failure
✗ FAILED: https://aka.ms/security.md/msrc/bounty - An error occurred while sending the request.

# After: retries with backoff
VERBOSE: Attempt 1/4 failed for https://aka.ms/... - retrying in 2s...
✓ OK: https://aka.ms/security.md/msrc/bounty (attempt 2)

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

- Replace Invoke-WebRequest built-in retry (only handles 5xx) with a
  manual retry loop that also catches transport-level exceptions
  (timeouts, TLS errors, DNS failures, etc.)
- Add exponential backoff: starts at RetryIntervalSec (2s), doubles
  each attempt, capped at 15s
- HEAD first each attempt; if HEAD throws a transport error OR returns
  404/405, fall back to GET for that same attempt before sleeping
- Add -MaximumRedirection 10 to all HTTP requests
- Change default timeout from 30s to 20s per request
- Change default retry count from 2 to 3 (4 total attempts)
- Log attempt count in pass/fail/ignore output lines
- Update action.yml and verify-markdown-links.yml defaults to match

Fixes transient CI failures like:
  "An error occurred while sending the request."
on known-good URLs (e.g. aka.ms/security.md/msrc/bounty, microsoft.com/msrc)
that pass after retrying.

Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Copilot AI changed the title [WIP] Update markdown link verification for resilience against network failures Harden markdown link checker against transient network failures Jul 22, 2026
Copilot AI requested a review from TravisEz13 July 22, 2026 20:38
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