Skip to content

Fix validation.links.not_found level always capped to INFO for links to excluded pages - #4104

Open
OfekDanny wants to merge 2 commits into
mkdocs:masterfrom
OfekDanny:fix/3900-included-page-link-to-excluded-page-log-level
Open

OfekDanny wants to merge 2 commits into
mkdocs:masterfrom
OfekDanny:fix/3900-included-page-link-to-excluded-page-log-level

Conversation

@OfekDanny

Copy link
Copy Markdown

Fixes #3900.

Problem

When an included page links to an excluded page, the warning level was computed as:

warning_level = min(logging.INFO, self.config.validation.links.not_found)

logging.INFO is 20, so any level ≥ WARNING (30) gets silently capped to INFO. This means setting validation.links.not_found: warn (or error) has no effect for links pointing to excluded pages — the message always appears at INFO.

The parallel branch for excluded-to-excluded links (a few lines above) correctly uses logging.DEBUG with no cap against the config value, so the inconsistency was unintentional.

Fix

Remove the min(logging.INFO, …) cap and use the configured level directly:

# before
warning_level = min(logging.INFO, self.config.validation.links.not_found)
# after
warning_level = self.config.validation.links.not_found

Tests

Added test_link_to_excluded_page_respects_not_found_level which renders an included page that links to a file marked as InclusionLevel.EXCLUDED and asserts the log record appears at the configured level (warn → WARNING, info → INFO). Before the fix, the warn sub-test would fail because the log appeared at INFO instead of WARNING.

…uded pages (mkdocs#3900)

When an included page links to an excluded page, the log level was
always capped to INFO via `min(logging.INFO, ...)`, ignoring the user's
configured `validation.links.not_found` level (e.g. `warn` or `error`).
Remove the cap so the configured level is respected.
… pages

test_draft_pages_with_invalid_links was written against the old capped
behavior. The default not_found level is 'warn' (WARNING), so now that
the min(INFO, …) cap is removed these messages correctly appear at
WARNING level.
@OfekDanny

Copy link
Copy Markdown
Author

The remaining CI failures (test_serve_default, test_serve_dev_addr, test_serve_dirtyreload, test_serve_no_directory_urls, test_draft_docs_with_comments_from_user_guide) are pre-existing on master and unrelated to this PR. I verified locally — they fail on master without any of my changes applied.

The only tests my change affects are in test_draft_pages_with_invalid_links (already updated in this PR: INFO → WARNING to match the corrected behavior) and the new test_link_to_excluded_page_respects_not_found_level which specifically regression-tests the fix.

This branch has not been deployed

No deployments
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.

validation.links.not_found is always reported as INFO

2 participants