Skip to content

chore: Lint internal path literals in application code - #19812

Open
coolguyzone wants to merge 3 commits into
masterfrom
coolguyzone/chore/lint-code-link-literals
Open

coolguyzone wants to merge 3 commits into
masterfrom
coolguyzone/chore/lint-code-link-literals

Conversation

@coolguyzone

Copy link
Copy Markdown
Contributor

DESCRIBE YOUR PR

The trailing-slash linter from #19666 only reads docs/, includes/ and platform-includes/ — so internal paths written in components were never checked. A component renders on many pages, which makes a slash-less path there cost considerably more than one in a single doc.

An audit of 300 rendered pages against production turned up seven:

File Count Notes
src/components/featureInfo.tsx 6 renders on platform pages
src/components/apiPage/index.tsx 1 <SmartLink to="/api/auth">
src/components/specMeta.tsx 1 develop-docs

All fixed here. Five just needed the slash. /product/tracing/ 308s even with one — tracing concepts moved to /concepts/key-terms/tracing/ — so that link gets the real destination rather than a slash.

New linter: pnpm lint:code-links

Added as a step on the existing non-blocking trailing-slash workflow, which now also triggers on src/ and app/.

Report-only, with no --fix — deliberately. A slash-prefixed literal in code is not reliably a link, and two of the ten the first pass found must keep their current form:

  • app/platform-redirect/page.tsx compares a pathname with the trailing slash stripped:

    pathname.replace(/\/$/, '') === '/tracing/instrumentation/automatic-instrumentation'

    Adding a slash would break the comparison. The line carries a trailing-slash-ignore marker explaining why.

  • src/internalLinkTracking.ts documents its own normalization in a JSDoc comment: "/product/logs and /product/logs/ both become /product/logs/". Rather than mark that, the linter skips comment lines — a path in a comment is never a rendered link, and reporting it would invite someone to "fix" prose that is deliberately showing both forms.

An auto-fixer would have corrupted both. That's the reason this one reports instead.

Verification

  • pnpm lint:code-links is clean on this branch
  • 18 unit tests covering the exemptions, comment handling and the ignore marker (276 across the suite)
  • The <a>-vs-<Link> eslint warnings in the touched components are pre-existing: 8 on master, 8 after this change

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

The trailing-slash linter from #19666 only reads docs/, includes/ and
platform-includes/, so internal paths written in components were never
checked. A component renders on many pages, which makes each one cost
more than a slash-less link in a single doc. An audit of 300 rendered
pages found seven:

  src/components/featureInfo.tsx       6  (renders on platform pages)
  src/components/apiPage/index.tsx     1
  src/components/specMeta.tsx          1  (develop-docs)

All are fixed here. Five just needed the slash; /product/tracing/ 308s
even with one, since tracing concepts moved to /concepts/key-terms/
tracing/, so that link gets the real destination.

Adds scripts/lint-code-link-literals.ts and `pnpm lint:code-links`, plus
a step on the existing non-blocking workflow, which now also triggers on
src/ and app/.

Report-only, with no --fix, because a slash-prefixed literal in code is
not reliably a link. Two of the ten the first pass turned up must keep
their current form:

- app/platform-redirect/page.tsx compares a pathname with the trailing
  slash stripped. Adding one would break the comparison, so the line
  carries a `trailing-slash-ignore` marker explaining why.
- internalLinkTracking.ts documents its own normalization in a JSDoc
  comment ("`/product/logs` and `/product/logs/` both become
  `/product/logs/`"). Rather than mark that, the linter skips comment
  lines: a path in a comment is never a rendered link, and reporting it
  would invite someone to "fix" the prose.

18 unit tests cover the exemptions, the comment handling and the marker.
The <a>-vs-<Link> eslint warnings in the touched components are
pre-existing -- 8 on master, 8 after this change.

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

vercel Bot commented Oct 5, 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 9, 2026 8:57pm UTC
sentry-docs Error Error Oct 9, 2026 8:57pm UTC

Request Review

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

cursor Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

The plan checks that help links still open their target pages. It also checks client errors on those pages. An issue escalates when target-page traffic falls or client errors rise. The tracing help link now opens a different page. Watch that new page.

Services: sentry-docs, develop-docs.

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

Plan

What changed

FeatureInfo learn-more links now include a trailing slash. Readers should reach those pages without a slash redirect. The tracing learn-more link now opens /concepts/key-terms/tracing/ instead of /product/tracing. The API auth link and the spec-lifecycle link now include a trailing slash. A new CI linter reports slash-less path literals in application code. That linter is not live traffic. sentry-docs and develop-docs must deploy before this change is live. Those services share the application source that this change edits. The platform-redirect edit is a comment only. It does not change runtime behavior.

Risk

A bad href sends readers to a missing page. FeatureInfo renders on many quick-start pages. One bad link then repeats across those pages. The tracing remap can strand readers if /concepts/key-terms/tracing/ fails. Shared components also ship to develop-docs. A render bug there would hit spec pages and the API page.

Intended effect

The new behavior is that those links open the slash-terminated pages. It is not the absence of errors. Client pageloads record the URL after a slash redirect. Sentry does not show the 308. Treat steady sampled pageloads on the destination paths as the reachable success signal. Absent: those destination counts fall while other docs traffic holds. Absent for the remap: /concepts/key-terms/tracing/ stays flat at zero while /product/tracing is the only tracing landing. Counts below are one 24h sample. User traces sample at 30 percent. Small moves are noise.

Signal Baseline Rule Source
Pageload or navigation on url.path /product/issues/ 50 sampled events in 2026-10-04T18:29:27Z to 2026-10-05T18:29:27Z Hold near this 24h count. Absent is a drop toward zero. Sentry sentry/docs production spans. Query: (span.op:pageload OR span.op:navigation) environment:production url.path:*product/issues* group by url.path. Read the /product/issues/ row.
Pageload on https://docs.sentry.io/concepts/key-terms/tracing/ 27 sampled events in 2026-10-04T18:29:27Z to 2026-10-05T18:29:27Z Hold or rise. Absent is a drop toward zero after deploy. Sentry sentry/docs production spans. Query: span.op:pageload environment:production http.url:*concepts/key-terms/tracing* group by http.url. Read the exact tracing URL row.

Regression watch

This diff can break FeatureInfo, ApiPage, or SpecMeta renders. It can also 404 the remapped tracing page. Client errors are the symptom on-call would see. Watch sibling FeatureInfo targets the same way. A drop on /product/logs/, /product/session-replay/web/, /product/user-feedback/, or /product/metrics/ is this change. Counts below are one 24h sample. Treat small moves as noise.

Signal Baseline Rule Source
Production client errors on docs 141 events in 2026-10-04T18:29:27Z to 2026-10-05T18:29:27Z. 140 used transaction /:path*?. Hold this 24h count. Detected is a clear rise above it. Sentry sentry/docs production errors. Query: environment:production with count() and group by transaction.
Production client errors on develop-docs 47 events in 2026-10-04T18:29:27Z to 2026-10-05T18:29:27Z Hold this 24h count. Detected is a clear rise above it. Sentry sentry/develop-docs production errors. Query: environment:production with count().

Not observable

Next.js trailing-slash 308 responses do not appear in Sentry spans. A search for http.status_code:308 on these paths returned no rows. HTTP 404 on the same paths also returned no rows. Do not treat those empty status queries as proof of health. /api/auth/ and /sdk/getting-started/standards/spec-lifecycle/ had zero sampled pageloads in that 24h window. The slash fix on those two links is not checkable from traffic. FeatureInfo click counts are mixed with all other inbound traffic. Plausible internal-link events exist in code. This session has no Plausible connector.

Comment thread scripts/lint-code-link-literals.ts Outdated
Reported by Sentry Bot on #19812, and correct.

Comments were detected with a per-line pattern anchored on `//`, `/*`
or `*`. A JSX comment opens with `{` first, so a quoted path inside one
was reported:

  {/* was <Link to="/product/logs"> before */}   -> flagged

Adding `{/*` to the pattern would not have been enough. JSX comments are
routinely written over several lines, and the inner lines look like
ordinary code:

  {/*
    <Link to="/product/metrics">metrics</Link>     -> flagged
  */}

So comments are now stripped with block state carried across lines,
rather than matched per line. That also fixes trailing comments on a
line of code, which the old pattern missed entirely since the line did
not start with a comment.

The stripper leaves a `//` preceded by `:` alone, so a URL scheme in a
string is not mistaken for a comment start -- otherwise
`const u = "https://x", p = "/one/two"` would have dropped the real path
after it and silently under-reported.

The bot's example used an unquoted path, which the literal pattern would
not have matched anyway; the underlying issue is real for quoted ones.
Its suggested symptom ("convert to <CodeLink />") does not match this
linter, which only ever proposes a trailing slash.

Nine behaviors covered by tests, including that flagging resumes after a
block closes and that code before an opening `/*` on the same line is
still checked. Still clean against the repo.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Comment thread scripts/lint-code-link-literals.ts
`stripComments` searched for `//` without tracking quote state, so a
protocol-relative check like `src.startsWith('//')` -- which `config/images.ts`
and `imageLightbox/index.tsx` both use -- truncated the line. Any path literal
written after it on the same line went unreported.

Nothing is missed on this branch today (the linter is still clean, and the five
non-test lines that truncate have no path after the cut), but the gap is silent
by nature: it only ever produces a false negative.

Scans character by character instead, tracking quote and block state, which
also fixes `/*` inside a string being read as a block-comment opener.

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

This branch had an error being deployed

1 failed and 1 active deployments
Preview – sentry-docs — 9995073d Deployed Oct 9, 2026 by vercel[bot]
Preview – develop-docs — 9995073d Deployed Oct 9, 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