Skip to content

linkcheck: Fix 'linkcheck_allowed_redirects' sentinel #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

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).

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.
Edit: in the final merged result, a sentinel value is retained; update the description accordingly.

@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
@bsipocz
Copy link
Contributor

bsipocz commented Aug 18, 2025

Can we get this merged please? the sphinx-astropy tests are failing with the dev version of sphinx for a while due to this for a while. However, in the meantime a new failure is popped up that we didn't notice at first as the job was failing for a while already.

@AA-Turner AA-Turner changed the title linkcheck: replace 'linkcheck_allowed_redirects' default sentinel with boolean false value linkcheck: Fix 'linkcheck_allowed_redirects' sentinel Aug 18, 2025
@AA-Turner AA-Turner merged commit e8ab5cf into sphinx-doc:master Aug 18, 2025
32 of 34 checks passed
@AA-Turner
Copy link
Member

@jayaddison sorry for the delay. I kept the sentinel but fixed the underlying problem.

@bsipocz please could you see if this fixes the problems for astropy?

A

@bsipocz
Copy link
Contributor

bsipocz commented Aug 18, 2025

@AA-Turner - Actually, this fixed both of the issues we saw in the most recent runs. Thank you!

@jayaddison jayaddison deleted the issue-13462/fix-linkcheck-theme-regression-when-allow-redirects-is-none branch August 18, 2025 22:33
@jayaddison
Copy link
Contributor Author

Thank you @AA-Turner @bsipocz!

From a brief glance earlier, I have a feeling that one of those failures may be an intermittent intersphinx problem unrelated to these changes - it's good if it appears to have gone away, but I'd (personally) stay on the lookout for it reoccurring. I hadn't gotten to the stage of trying to figure out how/why it occurs, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible regression in linkcheck_allowed_redirects default following PR 13452
4 participants