Skip to content

Fix anchor validation disabled in DEBUG log level#4084

Closed
danielalanbates wants to merge 1 commit intomkdocs:masterfrom
danielalanbates:fix/issue-3927
Closed

Fix anchor validation disabled in DEBUG log level#4084
danielalanbates wants to merge 1 commit intomkdocs:masterfrom
danielalanbates:fix/issue-3927

Conversation

@danielalanbates
Copy link

Summary

Fixes #3927.

When running MkDocs with --verbose (DEBUG log level), anchor validation was silently disabled. The guard if log.getEffectiveLevel() > logging.DEBUG on line 291 of pages.py prevented links_to_anchors from being populated when the log level was set to DEBUG (value 10), since 10 > 10 is False.

This one-line fix removes the conditional so that links_to_anchors is always assigned after rendering, regardless of the active log level.

Changes

  • Removed the log.getEffectiveLevel() > logging.DEBUG guard in Page.render() that prevented self.links_to_anchors from being set in verbose mode.

Test plan

  • All existing page structure tests pass (70 passed)
  • All anchor-related build tests pass (5 passed)
  • Verified that the logging import is still needed elsewhere in the file

This PR was created with the assistance of Claude sonnet-4-5 by Anthropic. Happy to make any adjustments! Reviewed and submitted by a human.

Remove the `log.getEffectiveLevel() > logging.DEBUG` guard that
prevented `links_to_anchors` from being populated when running
with verbose/DEBUG logging. This caused anchor validation to
silently stop working in debug mode.

Fixes mkdocs#3927

Co-Authored-By: Claude sonnet-4-5 <[email protected]>
@danielalanbates
Copy link
Author

Thank you for your time reviewing this. We're withdrawing this PR. Apologies for any inconvenience.

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.

Don't disable anchor validation in DEBUG mode

1 participant