From a94d7a84d71948b86465d39b16b5609352427575 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 1 Jun 2026 20:28:01 -0500 Subject: [PATCH 1/3] PYTHON-5847 Fix intermittent linkcheck failures due to dochub rate-limiting Set linkcheck_workers=1 to serialize requests to dochub.mongodb.org and increase linkcheck_timeout=60 to give slow redirects more room before retrying. --- doc/conf.py | 4 ++++ uv.lock | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 6d648ca503..8a0291aeb9 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -98,6 +98,10 @@ # Allow for flaky links. linkcheck_retries = 3 +# Serialize requests to dochub.mongodb.org to avoid rate-limiting (PYTHON-5847). +linkcheck_workers = 1 +# Give slow redirects more time before retrying. +linkcheck_timeout = 60 # -- Options for extensions ---------------------------------------------------- autoclass_content = "init" diff --git a/uv.lock b/uv.lock index 423b8d8373..8fa2282826 100644 --- a/uv.lock +++ b/uv.lock @@ -1601,7 +1601,7 @@ requires-dist = [ { name = "python-snappy", marker = "extra == 'snappy'", specifier = ">=0.7.3" }, { name = "readthedocs-sphinx-search", marker = "extra == 'docs'", specifier = "~=0.3" }, { name = "requests", marker = "extra == 'ocsp'", specifier = ">=2.23.0,<3.0" }, - { name = "service-identity", marker = "extra == 'ocsp'", specifier = ">=23.1.0" }, + { name = "service-identity", marker = "extra == 'ocsp'", specifier = ">=24.2.0" }, { name = "sphinx", marker = "extra == 'docs'", specifier = ">=5.3,<9" }, { name = "sphinx-autobuild", marker = "extra == 'docs'", specifier = ">=2024.10.3" }, { name = "sphinx-rtd-theme", marker = "extra == 'docs'", specifier = ">=3.1.0,<4" }, From 9be4eb5ba26a94b49065abf29c9dba137060b64c Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 2 Jun 2026 05:57:52 -0500 Subject: [PATCH 2/3] fix handling of github links --- .github/workflows/test-python.yml | 2 ++ doc/conf.py | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index ea6d237454..5427596ec5 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -172,6 +172,8 @@ jobs: run: just install - name: Build docs run: just docs-linkcheck + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} typing: name: Typing Tests diff --git a/doc/conf.py b/doc/conf.py index 8a0291aeb9..a56007e546 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -4,6 +4,7 @@ # This file is execfile()d with the current directory set to its containing dir. from __future__ import annotations +import os import sys from pathlib import Path @@ -86,11 +87,6 @@ # sourceforge.net is giving a 403 error, but is still accessible from the browser. # Links to release notes in jira give 401 error: unauthorized. PYTHON-5585 linkcheck_ignore = [ - "https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-monitoring.md#requesting-an-immediate-check", - "https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/transactions-convenient-api.md#handling-errors-inside-the-callback", - "https://github.com/mongodb/specifications/blob/master/source/uri-options/uri-options.md", - "https://github.com/mongodb/specifications/blob/master/source/uri-options/uri-options.md", - "https://github.com/mongodb/libmongocrypt/blob/master/bindings/python/README.rst#installing-from-source", r"https://wiki.centos.org/[\w/]*", r"https://sourceforge.net/", r"https://jira\.mongodb\.org/secure/ReleaseNote\.jspa.*", @@ -103,6 +99,17 @@ # Give slow redirects more time before retrying. linkcheck_timeout = 60 +# Ignore anchors in links since they may not be added to the page right away. +linkcheck_anchors_ignore = True + +# Pass GitHub token to avoid rate-limiting on GitHub links. +if github_token := os.environ.get("GITHUB_TOKEN"): + linkcheck_request_headers = { + "https://github.com/": {"Authorization": f"token {github_token}"}, + "https://api.github.com/": {"Authorization": f"token {github_token}"}, + } + + # -- Options for extensions ---------------------------------------------------- autoclass_content = "init" From 2a7b50ffcd91bdbbaaae093f1eab59a9ff45caa6 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 2 Jun 2026 06:01:54 -0500 Subject: [PATCH 3/3] fix config --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index a56007e546..9e617eb833 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -100,7 +100,7 @@ linkcheck_timeout = 60 # Ignore anchors in links since they may not be added to the page right away. -linkcheck_anchors_ignore = True +linkcheck_anchors_ignore_for_url = [r"https://github.com/.*"] # Pass GitHub token to avoid rate-limiting on GitHub links. if github_token := os.environ.get("GITHUB_TOKEN"):