Skip to content

fix(docs-mcp): strip query strings and fragments from docs URLs - #1767

Open
pcbeingused333 wants to merge 4 commits into
getsentry:mainfrom
pcbeingused333:fix/docs-url-strip-query-fragment
Open

pcbeingused333 wants to merge 4 commits into
getsentry:mainfrom
pcbeingused333:fix/docs-url-strip-query-fragment

Conversation

@pcbeingused333

Copy link
Copy Markdown

Fixes #1618

Cause. normalizeDocPath in apps/docs-mcp/src/sentry-docs/fetcher.ts keeps ?query and #fragment, and fetchDocPage then appends .md to the whole string. https://docs.sentry.io/platforms/javascript/#tracing becomes a request for /platforms/javascript/ with fragment #tracing.md, so the server returns the HTML page, which is cached as Markdown for an hour.

Fix. Strip the query string and fragment first, before the origin, .md, trailing-slash and leading-slash steps. The exact-origin boundary is unchanged (https://docs.sentry.io.example.com/...?x=1 is still treated as a path, not as docs.sentry.io). Every caller of normalizeDocPath (fetchDocPage, the agent tools, the doctree and the citation URLs) gets the cleaned pathname.

Tests. apps/docs-mcp/src/__tests__/fetcher.test.ts gains cases for full URLs and relative paths with a query, a fragment or both, for the bare origin with ?/#, for the origin boundary with a query string, and a fetchDocPage test that checks the outbound request URL is https://docs.sentry.io/platforms/javascript.md.

This change was prepared with the assistance of an AI tool (Claude) and submitted by the account owner.

pcbeingused333 and others added 4 commits October 31, 2026 06:08
normalizeDocPath kept '?' and '#', so fetchDocPage appended '.md' to the whole
string and requested e.g. '#tracing.md' instead of '<pathname>.md'; the HTML
response was then cached as Markdown. Drop the query and fragment before the
other normalisation steps.

Fixes getsentry#1618

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…y and fragment

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…does

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 31, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Oct 31, 2026 12:44pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 31, 2026

This branch was previously deployed

1 inactive deployment
Preview — bb16f782 Deployed Oct 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs MCP URL normalization retains query strings and fragments

3 participants