Skip to content

fix(redirects): Apply redirects to .md export URLs - #20336

Merged
BYK merged 4 commits into
masterfrom
shannonanahata/mar-1919-redirects-not-applied-to-md-doc-urls
Nov 6, 2026
Merged

BYK merged 4 commits into
masterfrom
shannonanahata/mar-1919-redirects-not-applied-to-md-doc-urls

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

DESCRIBE YOUR PR

Fixes MAR-1919. Moved documentation pages redirected at their HTML URLs, but their .md exports could fall through to the Markdown soft-404 and return HTTP 200 "Page Not Found". Agents using cached URLs such as /product/sentry-mcp.md, /ai/mcp.md, /product/sentry-basics/sampling.md and /product/alerts.md would get stuck there.

  • middleware.ts: resolve .md requests through the existing HTML redirect map, including :guide placeholders, then redirect to the destination's .md export. External URLs and destinations with query strings stay unchanged; fragments are preserved.
  • redirects.js: fold HTML and .md matches into each eligible page rule using :mdSuffix. Destinations that cannot share a rule, such as the root or a path ending in a parameter, get a separate .md rule immediately after the original. Wildcards with fixed internal destinations get a Markdown-specific rule before the catch-all, so /product/insights/http.md redirects to /product/dashboards/sentry-dashboards.md. More-specific redirects keep their precedence: /product/insights/mcp.md still reaches /product/mcp-servers.md. The generated user-docs rules total 829, below Next.js's 1,000-route warning.
  • Remove the 8 handwritten .md redirects now covered by the generated rules. The transformation runs in redirects(); the exported redirect arrays remain untransformed for the redirect-chain lint and rename check.

Wildcards forwarding :path* already carry the requested extension and stay unchanged. External URLs, destinations with query strings, and the /platform-redirect/ platform picker also stay unchanged.

The Markdown soft-404 still returns 200 on purpose, as explained in app/md-exports/[...path]/route.ts.

IS YOUR CHANGE URGENT?

  • Urgent deadline (GA date, etc.): YYYY-MM-DD
  • Other deadline: YYYY-MM-DD
  • No deadline: Not urgent, can wait up to 1 week+

PRE-MERGE CHECKLIST

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

via shannon.anahata.

--

View Junior Session [Sentry]

Redirects only matched the HTML URL, so the .md export of a moved page
fell through to the Markdown soft-404 (HTTP 200 "Page Not Found").

- middleware: look up the HTML path for .md requests and redirect to
  the destination's .md export (external destinations unchanged).
- redirects.js: derive a .md twin for every non-wildcard redirect and
  drop the 8 hand-written twins it now covers.

Refs MAR-1919

Co-Authored-By: Shannon Anahata <[email protected]>
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
develop-docs Ready Ready Preview Nov 5, 2026 10:09pm UTC
sentry-docs Ready Ready Preview Nov 5, 2026 10:09pm UTC

Request Review

@linear-code

linear-code Bot commented Oct 29, 2026

Copy link
Copy Markdown

MAR-1919

Generating a separate .md rule per redirect pushed next.config redirects
from 741 to 1,193, past Next's 1,000-route performance warning.

Match both URLs with one rule instead: the source ends in
:mdSuffix(/|\.md) and the destination reuses :mdSuffix, so /old/ goes to
/new/ and /old.md to /new.md. path-to-regexp rejects a param directly
after another param, so the 12 rules whose path ends in a param still
get a separate .md rule. Total: 745 rules.

Refs MAR-1919

Co-Authored-By: Shannon Anahata <[email protected]>
@cursor

cursor Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Getting ready to monitor this change · Rollout details

Status Service Environment
⏳ Getting ready to monitor this change

@sentry-junior

sentry-junior Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

getsentry/toolkit#2051 depends on this PR. It makes the Sentry MCP's get_doc tool return a not-found error for the .md soft 404. Until this lands, removed pages such as /ai/mcp.md (which redirects to mcp.sentry.dev) still get the generic "Page Not Found" body, and agents can't find where the page went. Could someone from docs review this?

@BYK
BYK merged commit 4ab73a8 into master Nov 6, 2026
32 checks passed
@BYK
BYK deleted the shannonanahata/mar-1919-redirects-not-applied-to-md-doc-urls branch November 6, 2026 19:23
BYK added a commit that referenced this pull request Nov 6, 2026
…20608)

## DESCRIBE YOUR PR

This revives most of #18953 by @sergical, which the stale bot closed.
It's rebased on current `master`, and @sergical is credited as co-author
on the commit. When an agent requests a `.md` page that has no export,
the response now explains why:

- **`/platform-redirect.md`** (the most-missed path) now serves guidance
from `md-overrides/platform-redirect.mdx` on building
`/platforms/<platform>/<page>.md` URLs directly. `/platform-redirect/`
is a dynamic route with no static HTML, so the override was never
emitted in #18953 (Bugbot's finding). A new `standalone: true` override
frontmatter flag lets `generate-md-exports` emit an override without a
matching HTML page. Overrides without the flag still get the "did not
match any HTML file" warning, so typos are still caught.
- **Pages that exist but whose export is missing** get a "Markdown
Export Unavailable" body that links to the HTML page and the page's
children, with a 60s cache. Synthetic doctree nodes (`missing: true`)
only fill gaps in the hierarchy, so they keep the generic "Page Not
Found" response. This fixes Bugbot's second finding.
- `docs.md_export.not_found` gains an `outcome` attribute (`page_exists`
| `unknown_path`).

**Dropped:** the "Page Moved" response for redirected paths, together
with its `middleware.ts` exports and redirect-table lookup. #20336
already makes `.md` requests for moved pages follow the redirect map
with a 308, for example `/ai/mcp.md` → mcp.sentry.dev. Two different
answers for the same request would conflict.

The response keeps its 200 status, the `X-Sentry-Docs-Not-Found: 1`
header and noindex. getsentry/toolkit#2051 relies on that header to
detect these misses.

I updated the route tests: I removed the redirect cases and added one
for synthetic nodes. `vitest` passes (527 tests), and ESLint and
Prettier are clean on the changed files. `generate-md-exports.mjs` runs
on import, so the standalone branch has no unit test. Checking
`/platform-redirect.md` on the Vercel preview will verify it.

## IS YOUR CHANGE URGENT?

- [ ] Urgent deadline (GA date, etc.): YYYY-MM-DD
- [ ] Other deadline: YYYY-MM-DD
- [x] No deadline: Not urgent, can wait up to 1 week+

## PRE-MERGE CHECKLIST

- [ ] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A2b57bf9a8da1beded651ceb5801db51f -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A2b57bf9a8da1beded651ceb5801db51f)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A2b57bf9a8da1beded651ceb5801db51f/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Burak Yigit Kaya <[email protected]>

This branch was successfully deployed

2 active deployments
Preview – sentry-docs — 0bd98ed6 Deployed Nov 5, 2026 by vercel[bot]
Preview – develop-docs — 0bd98ed6 Deployed Nov 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: Normal Docs review has no urgent deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant