Skip to content

Comments

Extend linkcheck GET fallback to handle TooManyRedirects (swev-id: sphinx-doc__sphinx-8475)#58

Open
casey-brooks wants to merge 1 commit intosphinx-doc__sphinx-8475from
fix/linkcheck-too-many-redirects
Open

Extend linkcheck GET fallback to handle TooManyRedirects (swev-id: sphinx-doc__sphinx-8475)#58
casey-brooks wants to merge 1 commit intosphinx-doc__sphinx-8475from
fix/linkcheck-too-many-redirects

Conversation

@casey-brooks
Copy link

Summary

  • extend the HEAD→GET fallback to also catch requests.exceptions.TooManyRedirects
  • add regression coverage for successful fallback and persistent failures after GET
  • introduce a focused linkcheck test root for TooManyRedirects scenarios

Reproduction

  1. Create /workspace/repro with the minimal conf.py and index.rst described in the issue.
  2. Run sphinx-build -b linkcheck /workspace/repro /workspace/repro/_build/linkcheck -v.

Observed failure (before fix):

index.rst:4: [broken] https://idr.openmicroscopy.org/webclient/?show=well-119093: Exceeded 30 redirects.

Python traceback showing TooManyRedirects on HEAD:

Traceback (most recent call last):
  File "/workspace/repro/too_many_redirects.py", line 7, in <module>
    requests.head(URL, allow_redirects=True, timeout=30)
  File "/workspace/sphinx/.venv/lib/python3.11/site-packages/requests/api.py", line 100, in head
    return request("head", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspace/sphinx/.venv/lib/python3.11/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspace/sphinx/.venv/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspace/sphinx/.venv/lib/python3.11/site-packages/requests/sessions.py", line 724, in send
    history = [resp for resp in gen]
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/workspace/sphinx/.venv/lib/python3.11/site-packages/requests/sessions.py", line 724, in <listcomp>
    history = [resp for resp in gen]
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/workspace/sphinx/.venv/lib/python3.11/site-packages/requests/sessions.py", line 191, in resolve_redirects
    raise TooManyRedirects(
requests.exceptions.TooManyRedirects: Exceeded 30 redirects.

Validation

  • pytest tests/test_build_linkcheck.py -q
  • pytest -q (fails on existing branch due to longstanding mismatches in autodoc, intl, and html code-block expectations — unchanged by this patch)
  • sphinx-build -b linkcheck /workspace/repro /workspace/repro/_build/linkcheck -v

Post-fix output excerpt:

(line    4) ok        https://idr.openmicroscopy.org/webclient/?show=well-119093

@casey-brooks casey-brooks requested a review from a team December 26, 2025 17:32
@casey-brooks
Copy link
Author

Test & Lint Summary:\n- \ → 19 passed, 0 failed\n- \ → fails on existing baseline (html code-block lineno assertions, autodoc expectations, intl translation checks); unchanged by this patch\n- No standalone lint command provided in this branch

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

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

Extends the HEAD→GET fallback to cover TooManyRedirects and adds solid regression tests. Verified the new fixtures and monkeypatch-based tests; everything looks clean.

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