Skip to content

check_redirects.py: flag redirects over unlisted pages and loops through wildcard destinations #2380

Open

Description

@palango

Two gaps in scripts/check_redirects.py came up in the review of #2369. Neither shows up in docs.json today.

A redirect whose source is a real page on disk is dead: Mintlify serves the page and the redirect never fires (checked with mint dev in the #2369 review). The check only catches this when the page is in navigation. A page that exists on disk but isn't in navigation, such as hidden.mdx with a redirect from /hidden, passes. The fix is to test whether the page exists for each source as well as navigation. Wildcard sources need some thought: does /a/:slug* over an existing /a/b.mdx fire, or does the page win? That needs checking against mint dev first.

The check deliberately doesn't follow chains through wildcard destinations, because section renames rely on them (/build-on-celo/:slug* → /build/:slug* → newer exact entries). As a result, /p/:slug* → /q/:slug* together with /q/:slug* → /p/:slug* loops and passes. A walk of at most five hops that fails on a repeated source would catch loops without flagging the chains we want.

Both need unit tests in scripts/test_check_redirects.py alongside the existing cases.

Activity

  1. palango commented on Oct 7, 2026

    @palango
    ContributorAuthor

    One more case from the latest #2369 review: a wildcard that redirects to itself, /p/:slug* to /p/:slug*, also passes the check today. It is the cheapest loop to catch, since it needs no walk at all, just a source equal to its destination. It belongs with the loop check above and needs its own unit test.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions