Skip to content

fix(platform-redirect): Keep the anchor of the next path - #20227

Open
RaphaelFakhri wants to merge 1 commit into
getsentry:masterfrom
RaphaelFakhri:fix/platform-redirect-keep-anchor
Open

RaphaelFakhri wants to merge 1 commit into
getsentry:masterfrom
RaphaelFakhri:fix/platform-redirect-keep-anchor

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

DESCRIBE YOUR PR

PlatformLink encodes its target when no platform is active, so a link such as <PlatformLink to="/configuration/options/#ignoreErrors"> renders as /platform-redirect/?next=%2Fconfiguration%2Foptions%2F%23ignoreErrors. sanitizeNext keeps only the path, so both the redirect and the links in the platform list drop the anchor, and readers land at the top of a long page such as Options instead of the option the link points to.

For example, this request redirects to /platforms/python//configuration/options/ with no #tracing-options:

curl -sI 'https://docs.sentry.io/platform-redirect/?next=/configuration/options/%23tracing-options&platform=python'

About 900 PlatformLink uses in docs/ and the includes have an anchor, for example on the Issues and errors getting started guide.

This change adds sanitizeNextHash, which returns the fragment of next limited to the characters used in heading and option ids (letters, digits, _, -, .), and appends it to the redirect target and to the platform list links. sanitizeNext and its same-origin checks are unchanged, and a fragment cannot change the origin of the redirect.

Tests: app/platform-redirect/utils.spec.ts covers encoded and plain fragments, dotted option ids, unsafe characters, and malformed encoding.

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

LEGAL BOILERPLATE

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

EXTRA RESOURCES

Fixes #20226

PlatformLink encodes its target, so a link such as
/configuration/options/#ignoreErrors reaches /platform-redirect as
next=%2Fconfiguration%2Foptions%2F%23ignoreErrors. sanitizeNext only
keeps the path, so the redirect and the platform list dropped the
anchor and readers landed at the top of the page.

Add sanitizeNextHash, which returns the fragment limited to id
characters, and append it to the redirect and platform list URLs.
@vercel

vercel Bot commented Oct 24, 2026

Copy link
Copy Markdown

@RaphaelFakhri is attempting to deploy a commit to the Sentry Team on Vercel.

A member of the Team first needs to authorize it.

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

cursor Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

The plan checks that platform redirects keep the section marker. It also checks the redirect failure rate and 404s on platform pages. An issue escalates when those redirects fail or platform 404s rise.

Services: sentry-docs.

Mention @change-monitor in a comment to update the plan.

Plan

What changed

Requests to /platform-redirect/ now keep the section marker on the redirect target. The platform list links keep the same marker. The change is live after sentry-docs deploys.

Risk

A bad fragment can make the server redirect throw. Readers then see an error instead of the docs page. A fragment that joins the path can send readers to a missing platform page. The blast reaches every platform redirect. About 900 docs links carry a section marker. Path origin checks are unchanged. A fragment cannot change the redirect origin.

Intended effect

The new behavior is a Location header that ends with the section marker. absent means 307 responses continue and Location still has no marker. Sentry spans record the request URL. They do not record the Location fragment. Sampled GET spans with %23 in the URL are the population that should keep the marker. That share was 4.5% of GET /platform-redirect spans. Compare the issue symptom to 0. Do not treat a steady 307 rate as proof the marker is present.

Signal Baseline Window Rule Source
Redirect Location drops the section marker. The page opens at the top. 100% of matching requests drop the marker. 141 of 3117 sampled GET /platform-redirect spans carried %23. 2026-10-23T18:31:18Z to 2026-10-24T18:31:18Z Symptom must stay at 0. Sentry org sentry project docs. Query: span.op:http.server http.request.method:GET url.full:"*/platform-redirect*" url.full:"*%23*" sentry.environment:production. Fixes issues/20226

Regression watch

A throw on the new fragment path would raise failures on GET /platform-redirect. A fragment that joins the path would raise platform 404s. Watch those signals. User traces sample at 30%. Use rates. Do not treat sampled counts as total traffic.

Signal Baseline Window Rule Source
GET /platform-redirect span failure rate 0% over 24h and 48h. 0.10% over 7d. Band 0-0.10%. 2026-10-17T18:31:18Z to 2026-10-24T18:31:18Z Hold in 0-0.10%. Escalate above 0.10%. Sentry org sentry project docs. Query: sentry.segment.name:"GET /platform-redirect" span.op:http.server sentry.environment:production. Aggregates: failure_rate(), count(), p95(span.duration). 24h count 3117. 48h count 7477. 7d count 28987.
GET /platform-redirect error events 0 events in 24h. 37 events in 7d. All titles were ReferenceError: location is not defined. Rate 0-0.13% of GET /platform-redirect spans. 2026-10-17T18:31:18Z to 2026-10-24T18:31:18Z Hold the 24h error rate in 0-0.13%. Escalate on a new title or a rate above 0.13%. Sentry org sentry project docs. Query: environment:production transaction:"GET /platform-redirect".
HTTP 5xx on GET /platform-redirect 0 of 3107 sampled spans. Status mix was 3010 times 200 and 97 times 307. 2026-10-23T18:31:18Z to 2026-10-24T18:31:18Z Hold 5xx at 0. Sentry org sentry project docs. Query: span.op:http.server http.request.method:GET span.description:"GET /platform-redirect" sentry.environment:production. Group by http.response.status_code.
docs.page.not_found for requested_path platforms* 69 in 24h. 163 in 48h. 381 in 7d. Per-day band 54-94. 2026-10-17T18:31:18Z to 2026-10-24T18:31:18Z Hold the 24h count in 54-94. Escalate above 94. If the count rises, inspect redirect targets for a marker joined into the path. Sentry org sentry project docs. Metric docs.page.not_found with sentry.environment:production requested_path:platforms*.

Not observable

Sentry does not record the Location fragment. The executor cannot confirm the section marker from spans. Record intended_effect as unknown unless Location is inspected. A 7d HTTP status mix for GET /platform-redirect was not measured. The 7d %23 query that used url.path:/platform-redirect returned 0 and is not trusted. Picker HTML that adds the marker is not in traces until a reader follows the link.

This branch has not been deployed

No deployments
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

1 participant