Skip to content

linkcheck: replace 'linkcheck_allowed_redirects' default sentinel with boolean false value #13483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

jayaddison
Copy link
Contributor

@jayaddison jayaddison commented Apr 14, 2025

Purpose

Patches the linkcheck module so that linkcheck_allowed_redirects is never assigned a value of None -- this was failing to typecheck against the allowed values for the config value when HTML themes were enabled (ref: #13462).

Specifically: this pull request updates the default value of linkcheck_allowed_redirects from the previous sentinel value to a new value of False.

Linkchecking and allowed redirections behaviour

When the linkcheck builder follows a hyperlink that redirects, the link is considering working when either of the following occur:

  • The server issues a redirect back to the same URL (with any trailing-slashes removed).
  • A matching {origin, destination} pattern pair for the server-issued redirect is found in linkcheck_allowed_redirects.

All other redirects are reported with the redirected status code.

When linkcheck_allowed_redirects is configured -- e.g. set to any other value than the default of False -- hyperlinks that encounter redirects with no matching matching {origin, destination} pattern pair in the configuration value also emit a warning-level log message.

References

Edit: possible-values in this description requires redrafting; add a todo placeholder.
Edit: update proposed config value behaviours.
Edit: invert default value (was: true; now: false).
Edit: attempt to clarify this description.
Edit: describe the change-in-behaviour nearer the start of this description, reformat a few elements, and attempt to communicate the logic more clearly.
Edit: a correction about the existing default config value (sentinel), and a clarification about the described conditions under which redirected hyperlinks are considered working.

@pllim
Copy link

pllim commented May 6, 2025

FWIW this PR turns our downstream job from red to green: astropy/sphinx-astropy#82

Thanks!

@jayaddison
Copy link
Contributor Author

Thank you @pllim for testing it :)

@bsipocz
Copy link
Contributor

bsipocz commented May 27, 2025

Can we merge this please, so I don't keep getting the failing cron notifications 😄 ?

@jayaddison
Copy link
Contributor Author

@AA-Turner ping for possible code review?

@jayaddison

This comment was marked as resolved.

@jayaddison

This comment was marked as resolved.

@jayaddison jayaddison changed the title linkcheck: disallow 'None' value for 'linkcheck_allowed_redirects' setting linkcheck: replace 'linkcheck_allowed_redirects' default sentinel with boolean false value Jun 3, 2025
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.

Possible regression in linkcheck_allowed_redirects default following PR 13452
3 participants