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

Open
#2,380 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start with scripts/check_redirects.py and the existing cases in scripts/test_check_redirects.py. Check with mint dev whether a wildcard redirect source takes precedence over an existing page, then cover that behavior and add tests for detecting loops through wildcard destinations. Done when redirects from unlisted on-disk pages are checked and wildcard loops are caught without flagging the intended section-rename chains.

Written by the indexing model from the issue text.

Description

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.

Dominant language
MDX
Stars
89
Forks
396
Avg merge
3d 5h
Merged PRs (30d)
17

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from celo-org/docs

All issues in celo-org/docs

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.