Skip to content

fix(platform-redirect): Keep the anchor when no platform is selected - #20234

Merged
coolguyzone merged 1 commit into
masterfrom
coolguyzone/fix/platform-redirect-anchors
Oct 26, 2026
Merged

coolguyzone merged 1 commit into
masterfrom
coolguyzone/fix/platform-redirect-anchors

Conversation

@coolguyzone

Copy link
Copy Markdown
Contributor

DESCRIBE YOUR PR

Fixes #20226.

When no platform is active, PlatformLink points at /platform-redirect/?next=<encoded path>. sanitizeNext returned only url.pathname, so the anchor was dropped from both the redirect and the links on the selection page. Around 770 PlatformLink uses carry an anchor.

Reproduced before the fix:

$ curl -sI '.../platform-redirect/?next=/configuration/options/%23tracing-options&platform=python'
HTTP/2 307
location: /platforms/python//configuration/options/     ← no fragment, and a double slash

The fragment can't just be appended to the returned path — page.tsx feeds that value into nodeForPath(...pathname.split('/')), so a #frag segment would break doc tree resolution and fall through to "We couldn't find documentation for this path". So the path and the fragment are now returned separately, and only the two URL-building sites append the fragment.

  • sanitizeNext returns {pathname, hash}; every doc tree lookup keeps using pathname alone
  • Fragments are allowlisted (/^#[\w.-]+$/, which covers slugs like godot_logger.event_mask); an unrecognized fragment is dropped rather than failing the whole redirect
  • Adds platformUrlFor, which joins the platform URL with the path without leaving the // that made every platform redirect 308 a second time
  • Drive-by: four PlatformLinks had a trailing slash appended after the fragment by older trailing-slash tooling, so their anchors matched nothing. The two Flutter ones also pointed through a redirect at an id that no longer exists, and now go straight to /debug-symbols/#when-to-upload-debug-symbols

Security

The existing hardening is deliberately untouched — the colon guard still runs on the whole decoded string before parsing (so javascript:/data: are still rejected), the origin check is unchanged, and a fragment is only ever appended to a doc-tree-resolved URL, so it can't influence the origin. New tests cover /a/#@example.com and /a/#//example.com being dropped, plus %2523 double-encoding.

Verification

  • 516/516 vitest tests pass (25 in utils.spec.ts, up from 16)
  • tsc, eslint and prettier clean
  • pnpm lint:trailing-slash clean — the current linter is already fragment-aware, so the four fixed anchors don't regress

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.
Select exactly one option. For deadlines, replace YYYY-MM-DD with the due date. You can update this information later by editing the PR description.

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

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've supplied a deadline.

Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • 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

🤖 Generated with Claude Code

`PlatformLink` points at `/platform-redirect/?next=<encoded path>` when no
platform is active, and `sanitizeNext` returned only `url.pathname`, so the
fragment was dropped from both the redirect and the links on the selection
page. Around 770 `PlatformLink` uses carry an anchor.

The fragment can't simply be appended to the returned path: `page.tsx` feeds
that value into `nodeForPath(...pathname.split('/'))`, so a `#frag` segment
would break doc tree resolution and fall through to "We couldn't find
documentation for this path". `sanitizeNext` now returns the path and the
fragment separately, and only the URL-building sites append the fragment.

Fragments are allowlisted (`/^#[\w.-]+$/`, covering slugs like
`godot_logger.event_mask`) and an unrecognized one is dropped rather than
failing the whole redirect. The existing hardening is untouched: the colon
guard still runs on the whole decoded string before parsing, the origin check
is unchanged, and a fragment is appended only to a doc-tree-resolved URL.

Also adds `platformUrlFor`, which joins the platform URL with the path without
leaving the `//` that made every platform redirect 308 a second time
(`/platforms/python//configuration/options/`).

Drive-by: four `PlatformLink`s had a trailing slash appended after the
fragment by older trailing-slash tooling, so their anchors matched nothing.
The two Flutter ones also pointed through a redirect at an id that no longer
exists, and now go straight to
`/debug-symbols/#when-to-upload-debug-symbols`.

Fixes #20226

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 26, 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 Oct 26, 2026 6:34pm UTC
sentry-docs Ready Ready Preview Oct 26, 2026 6:34pm UTC

Request Review

@github-actions github-actions Bot added the Priority: Normal Docs review has no urgent deadline label Oct 26, 2026
@codeowner-assignment
codeowner-assignment Bot requested review from a team October 26, 2026 18:28
@cursor

cursor Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Monitoring services · Rollout details

Status Service Environment
🔵 Deployed develop-docs production
🔵 Deployed sentry-docs production

Mention @rollout in a comment to update the plan.

@coolguyzone
coolguyzone merged commit 571b0b2 into master Oct 26, 2026
29 checks passed
@coolguyzone
coolguyzone deleted the coolguyzone/fix/platform-redirect-anchors branch October 26, 2026 23:24
@cursor

cursor Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Verified in production

  • Heading-fragment picker requests kept returning 200, and the route had no errors.
  • Heading-link picker requests stayed successful.

This branch was successfully deployed

2 active deployments
Preview – sentry-docs — 41358f0d Deployed Oct 26, 2026 by vercel[bot]
Preview – develop-docs — 41358f0d Deployed Oct 26, 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.

Platform links lose their anchor when no platform is selected

2 participants