Skip to content

Prevent unsafe redirect auto-fixes - #954

Open
hzagaming wants to merge 1 commit into
practical-tutorials:masterfrom
hzagaming:fix-unsafe-redirect-autofix
Open

Prevent unsafe redirect auto-fixes#954
hzagaming wants to merge 1 commit into
practical-tutorials:masterfrom
hzagaming:fix-unsafe-redirect-autofix

Conversation

@hzagaming

Copy link
Copy Markdown

Summary

Makes the automated link-rot fixer more conservative when deciding whether a redirected URL is safe to rewrite automatically.

Currently, most successful redirects are classified as OK unless they land on the domain root. This can cause unrelated destination pages to be treated as valid moved tutorials.

For example, the current automated link-rot PR #903 includes redirects where tutorial URLs now resolve to unrelated articles, such as the "Music Recommender using KNN" entry redirecting to an article about recommendation-system evaluation metrics.

Changes

  • add conservative redirect-safety classification
  • allow mechanical changes such as HTTP → HTTPS, www normalization, and trailing slashes
  • allow same-site path migrations when the resource slug is preserved
  • require human review for:
    • cross-domain redirects
    • changed article/resource slugs
    • query-string changes
    • non-default port changes
    • redirects to the domain root
  • add 9 regression tests covering safe and suspect redirects
  • run unit tests in the PR validation workflow when scripts/** or tests/** changes

Verification

  • PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s tests -v
    • 9 tests passed
  • PYTHONDONTWRITEBYTECODE=1 python3 scripts/check_readme.py lint
    • 0 errors
    • 0 warnings
  • git diff --check
    • passed

This intentionally favors false negatives over unsafe automatic URL replacements: ambiguous redirects remain available for human review rather than being automatically written into the README.

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.

1 participant