Add CI guard for relative links on index.md/index.mdx pages - #384
Merged
Conversation
Advisory-only guard modeled on the existing tools/ci/*-guard.py family: flags a relative (./ or ../) markdown link or HTML/JSX href authored on an index.md/index.mdx page, since that class of page resolves such links against the wrong parent folder in production (the bug fixed repo-wide in #375/#377). Skips fenced code, inline code spans, MDX imports, frontmatter, and the machine-generated reference trees. Never fails the build. Also documents the new check in contribute/automated-tests.mdx and tools/README.md, and references it from contribute/review/index.mdx's review checklist (itself an index.mdx page, which the guard confirms is still clean).
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an advisory-only CI guard, modeled on the existing
tools/ci/*-guard.py+.github/workflows/*-guard.ymlfamily (e.g.landing-page-template-guard,release-notes-api-structure-guard), that flags a relative (./or../) markdown link or HTML/JSXhrefauthored on anindex.md/index.mdxpage.This is the exact bug class root-caused and fixed repo-wide in #375 and #377: a page built from a literal
index.md/index.mdxfile serves at its folder's own bare path with no trailing slash, so a relative link written on that page resolves against the wrong parent folder in production. The target genuinely exists on disk, so no existing static check catches it (mint validatedoesn't check links at all;tools/triage-broken-links.pyresolves relative links via filesystem path math against the source file's disk location, not the live URL).tools/ci/check-index-relative-links.py: flags inline/reference-style markdown links and HTML/JSXhrefvalues starting with.//../onindex.md/index.mdxfiles. Skips fenced code blocks, inline code spans, MDXimportstatements, the YAML frontmatter block (redirect_from/relatedhold path-like values but aren't rendered links), and the machine-generated reference trees. Advisory only - always exits 0..github/workflows/index-relative-links-guard.yml: runs the script against a PR's changedindex.md/index.mdxfiles.env:rather than interpolating the${{ }}expression directly into therun:script body - direct interpolation is a known GitHub Actions script-injection vector (a filename containing$(...)/backticks could execute). Note: every sibling guard workflow in this repo shares that same latent pattern; out of scope to fix here, filing as a separate follow-up.contribute/automated-tests.mdx(new table row + detail section) andtools/README.md; referenced fromcontribute/review/index.mdx's "What to check" list.Note: found real leftover instances of this bug while building the guard
Running the new script against the current repo (not part of this PR's scope to fix) found #377's repo-wide fix was incomplete - roughly 172 relative links remain, almost entirely raw HTML
<a href="./...">links in landing-page "concept-links" card blocks that the earlier fix's markdown-only pattern didn't match, plus a handful of reference-style link definitions. Filing a separate follow-up issue/PR for that; not fixed here since #378 only asks for the guard.Closes #378
Test plan
redirect_from/related) plus 3 real hit shapes (markdown link, reference-style def, HTML href) - only the 3 real hits were flagged.--path contributeagainst the current repo (including the newly-editedcontribute/review/index.mdx) - zero hits, confirming the PR's own dogfood file stays clean.markdownlint-cli2on both touched content files - no new issues vs.main's baseline (the one MD053 hit oncontribute/review/index.mdxis a pre-existing, already-documented false positive, confirmed via diff againstorigin/main).contribute/review/index.mdx, an in-scope index page) and reports zero warnings.