Skip to content

fix(aeo): remove ua-based markdown serving - #47770

Merged
pamelachia merged 6 commits into
masterfrom
pamela/chatgpt-ua-markdown-fix
Jul 10, 2026
Merged

pamelachia merged 6 commits into
masterfrom
pamela/chatgpt-ua-markdown-fix

Conversation

@pamelachia

@pamelachia pamelachia commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The ChatGPT-User live-fetch agent's user-facing reader hard-fails ((400) OK) on pages we serve it as markdown via user-agent matching, which made supabase.com blog and product pages unreadable in that assistant. I root-caused this with a controlled fetch diagnostic cross-checked against our request logs: the failing fetches never reach our origin (the failure is cached on their side), pages served as plain HTML read fine everywhere we tested, and the same failure reproduces on other major sites that serve UA-matched markdown, so the reader bug is upstream.

This PR removes user-agent-based markdown serving entirely rather than special-casing one agent: UA sniffing is a guess about contractless clients whose fetchers change without notice, and this incident showed the failure mode is silent (we keep serving 200s while the user-facing agent breaks). Markdown remains available on every explicit signal — Accept: text/markdown q-value negotiation, explicit .md URLs, and llms.txt — which is the same contract-driven model the Claude fetcher already uses successfully (it sends Accept: text/markdown, text/html, */* and keeps receiving markdown after this change).

Changes

  • Remove the LLM_USER_AGENT regex and the userAgent parameter from negotiateMarkdown in packages/common/markdown-negotiation.ts; decisions now depend only on Accept, the .md suffix, and the markdown-variant manifest
  • Update both consuming middlewares (apps/www, apps/docs) to the new signature; no behavior change for Accept-negotiated or .md requests
  • Add the missing Vary: Accept header to docs guides-md 200 responses (the www api-v2/md route already declares it)
  • Fix a pre-existing www bug surfaced in review: explicit changelog .md URLs rewrote to a doubled .md.md path (404) under a markdown-preferring Accept, and 406'd on a non-matching Accept. The www middleware now strips the .md suffix before slug lookup and passes isMarkdownSuffix into negotiateMarkdown, folding the separate MD_PAGES .md block into the single negotiation path (same shape as the docs middleware)
  • Rework tests: UA-independence suites replace the per-agent rewrite tests; a probe Accept header now 406s regardless of user agent (previously agent UAs were exempt); new changelog .md negotiation coverage

Testing

Tested locally:

  • www middleware suite 36/36, docs middleware suite 17/17
  • typecheck green for common, www, docs

Verified on the Vercel previews (www + docs) with curl:

  • ChatGPT-User and Claude-User UA GETs on blog/pricing/guide pages return text/html with a default Accept
  • Claude's real Accept (text/markdown, text/html, */*) still returns text/markdown; Accept: text/markdown and .md URLs return text/markdown; probe Accept returns 406
  • /changelog/<slug>.md with Accept: text/markdown returns the entry markdown as a direct 200 (production today detours through a 308 to the bare URL); changelog index .md and bare-entry Accept negotiation also verified
  • docs guides markdown 200s carry Vary: Accept

The intermediate commit (ChatGPT-User-only exclusion) was already verified on the preview: ChatGPT-User got HTML while Accept/.md/other-UA markdown was unaffected.

Expected effects post-merge: UA-driven markdown volume in the request logs (~92% of md traffic) collapses to the Accept + .md baseline; named-agent page requests return to prerendered/static serving, reversing the extra Vercel function invocations the UA rewrite introduced; user-facing readability in the affected assistant recovers within ~24h as its fetch cache revalidates. The md-share dashboard gets a dated annotation; the ratio is not comparable across this change.

Linear

  • fixes GROWTH-973

Summary by CodeRabbit

  • Bug Fixes
    • Markdown and HTML routing now depends on the request’s Accept header and .md links, making content negotiation more predictable.
    • Requests that don’t accept available content now consistently return 406 Not Acceptable, even for bot-like user agents.
    • Guide markdown responses now include an Accept-based cache variation header to improve correct caching behavior.

@pamelachia
pamelachia requested review from a team as code owners July 9, 2026 09:40
@pamelachia pamelachia self-assigned this Jul 9, 2026
@vercel

vercel Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
zone-www-dot-com Ready Ready Preview, Comment, Open in v0 Jul 9, 2026 4:04pm
6 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Jul 9, 2026 4:04pm
design-system Skipped Skipped Jul 9, 2026 4:04pm
docs Skipped Skipped Jul 9, 2026 4:04pm
studio-self-hosted Skipped Skipped Jul 9, 2026 4:04pm
studio-staging Skipped Skipped Jul 9, 2026 4:04pm
ui-library Skipped Skipped Jul 9, 2026 4:04pm

Request Review

@supabase

supabase Bot commented Jul 9, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Markdown negotiation now uses only Accept and markdown suffix inputs. Guides markdown responses add Vary: Accept, and docs/www middleware and tests were updated to reflect Accept-driven rewriting and 406 behavior without user-agent-based forcing.

Changes

Markdown negotiation and cache variation

Layer / File(s) Summary
Negotiation core and response header
packages/common/markdown-negotiation.ts, apps/docs/app/api/guides-md/[...slug]/route.ts
negotiateMarkdown no longer accepts or checks userAgent, and successful guides markdown responses now include Vary: Accept.
Middleware wiring and route tests
apps/docs/middleware.ts, apps/www/middleware.ts, apps/docs/middleware.test.ts, apps/www/middleware.test.ts
Middleware passes only acceptHeader into negotiateMarkdown, and the docs/www tests now assert Accept-based rewrites, probe-header 406 handling, and non-rewrite fall-through without user-agent forcing.
Negotiator tests
packages/common/markdown-negotiation.test.ts
q-value and tie-breaking cases now omit explicit empty userAgent inputs while keeping the same Accept-driven outcomes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: spydon, jeremenichelli, ChrisChinchilla

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately states the main change: removing UA-based markdown serving.
Description check ✅ Passed The description covers the behavior change, current vs new behavior, testing, and extra context, though it doesn't match the template headings exactly.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pamela/chatgpt-ua-markdown-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pamelachia
pamelachia marked this pull request as draft July 9, 2026 09:45
@pamelachia pamelachia changed the title fix(aeo): drop chatgpt-user ua markdown serving fix(aeo): remove ua-based markdown serving Jul 9, 2026
@pamelachia
pamelachia marked this pull request as ready for review July 9, 2026 14:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/www/middleware.ts`:
- Around line 23-26: The changelog markdown rewrite still carries the .md
suffix, which can produce a doubled .md path when negotiating markdown. Update
the middleware flow in middleware.ts to strip the suffix from the changelog slug
before building the rewrite target, and pass the markdown-suffix state into
negotiateMarkdown so the decision logic can distinguish direct .md requests from
normal slugs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ac5397c2-76db-478c-9648-44990b94f498

📥 Commits

Reviewing files that changed from the base of the PR and between 7510f39 and daf3644.

📒 Files selected for processing (6)
  • apps/docs/middleware.test.ts
  • apps/docs/middleware.ts
  • apps/www/middleware.test.ts
  • apps/www/middleware.ts
  • packages/common/markdown-negotiation.test.ts
  • packages/common/markdown-negotiation.ts

Comment thread apps/www/middleware.ts Resolved
@pamelachia
pamelachia merged commit 770f1c2 into master Jul 10, 2026
36 checks passed
@pamelachia
pamelachia deleted the pamela/chatgpt-ua-markdown-fix branch July 10, 2026 05:50
@github-actions

github-actions Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1783662837)

Score Average Improvements Regressions
Knowledge Usage 89.7% (-10pp) - 3 🔴
Tool Usage 72.5% (-4pp) 1 🟢 2 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Time_to_first_token 4.22tok (+1.4tok) 4 🟢 25 🔴
Llm_calls 2.74 (-0.33) 8 🟢 14 🔴
Tool_calls 2.86 (-0.24) 6 🟢 16 🔴
Errors 5.23 (-0.07) 6 🟢 1 🔴
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 22233.4tok (-3691.15tok) 16 🟢 9 🔴
Prompt_cached_tokens 7232.74tok (-806.25tok) 10 🟢 16 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 588.55tok (-29.74tok) 20 🟢 9 🔴
Completion_reasoning_tokens 92.57tok (-5.49tok) 16 🟢 10 🔴
Total_tokens 22821.95tok (-3720.89tok) 18 🟢 11 🔴
Estimated_cost 0$ (0$) 16 🟢 12 🔴
Duration 19.07s (+1.79s) 6 🟢 23 🔴
Llm_duration 12.74s (+0.91s) 8 🟢 21 🔴

@coderabbitai coderabbitai Bot mentioned this pull request Jul 17, 2026
pamelachia added a commit that referenced this pull request Jul 27, 2026
The June/July marketing redesign (#47271, #47228) rebuilt the homepage
and product pages off the Pages Router, silently dropping their `<link
rel="alternate" type="text/markdown">` head tags, and llms-full.txt has
been accidentally embedding every blog/customer/event page via an
`MD_CONTENT` spread. I restored the tags behind a shared helper, added a
CI drift test so a future redesign can't drop them silently again, and
trimmed both llms files to the agreed docs-index shape.

**Changed:**

- **Markdown siblings advertised again**: homepage, the 5 product pages,
pricing, and blog emit absolute `.md` alternate URLs via a new
`mdAlternates(slug)` helper (the one documented consumer of the tag
parses it from `<head>` and fetches the `.md` sibling, so tags must
point at the sibling, never the page itself).
- **Drift test**: a vitest file walks `content/md/**` and asserts every
markdown-served slug's page wires the helper (or is covered by the Pages
Router `_app.tsx` mechanism, whose alternate-link wiring the test also
asserts directly so removing it fails CI too). Source-level assertions
by design: page modules can't be imported under www's vitest config.
Fails correctly when wiring is removed (verified by hiding a page and by
altering the `_app.tsx` tag).
- **Vector orphan fixed**: `content/md/vector.md` moved to
`modules/vector` matching the live route (the page previously had no
negotiation or tag, and `/modules/vector.md` 404'd); `/vector.md` now
308s to `/modules/vector.md` and the legacy `/llms/vector.txt` redirect
no longer chains.
- **llms.txt + llms-full.txt**: the `## Product Overview` sections are
gone from both, each keeps a `## Pricing` section. This deletes the
hand-maintained links array (a drift trap) and fixes the accidental
~470-page embed, shrinking llms-full.txt from ~9.8MB to ~4.9MB and
dropping the 4.1MB generated content module from that route's serverless
bundle.

**Note:** this PR is scoped to apps/www only. The docs side
(troubleshooting pages and the rest of the docs surface) is handled
separately through a consolidated manifest-gated mechanism; an earlier
troubleshooting-tag commit was reverted out of this branch to keep the
scopes clean.

<details>
<summary>Why alternate tags matter (background)</summary>

Agents ingest markdown far more efficiently than our rendered HTML: a
fraction of the tokens and no extraction step. Since #47770 removed
UA-based serving (UA sniffing broke a major AI app's fetcher and
poisoned CDN caches), markdown is served only on explicit request: a
`.md` suffix URL, an `Accept: text/markdown` header, or llms.txt. That's
the right serving model, but it makes the markdown twin invisible to any
agent that doesn't already know our URL convention, and the major AI
fetchers send browser/wildcard Accept headers, so bare URLs hand them
HTML.

The `<link rel="alternate" type="text/markdown">` head tag is the
standards-based advertisement of the sibling. It has a documented
consumer today: an agent CLI that parses the tag from `<head>` and then
fetches the `.md` sibling, which is also why the tag must point at a
real sibling URL and never at the page itself. Peer docs sites ship this
tag as table stakes. These www pages used to carry it until the
June/July marketing redesign silently dropped it; the drift test in this
PR turns that regression class into a CI failure.

</details>

## To test

Tested locally (www + docs dev servers):
- [x] `/llms.txt` renders `## Documentation` + single-link `## Pricing`,
no Product Overview
- [x] `/llms-full.txt` renders `# Supabase` → `## Pricing` → `##
Documentation`, no Product Overview, ~4.9MB
- [x] Full www suite: 6 files / 71 tests green; drift test fails
correctly when a page is removed or the `_app.tsx` wiring is altered
- [x] `generateMdContent.mjs` emits `modules/vector`, bare `vector` slug
gone

On the Vercel preview (browser-verified with Playwright):
- [x] Alternate tag present on `/`, `/auth`, `/database`, `/storage`,
`/edge-functions`, `/realtime`, `/pricing`, and a blog post: exactly one
tag each, href = preview origin + `.md` sibling
- [x] `/vector.md` → 308 → `/modules/vector.md`, renders as markdown (`#
Supabase Vector`)
- [x] `/llms.txt` shows single-link `## Pricing`, no Product Overview
- [x] Coverage sweep: all 482 `MD_PAGES` slugs + changelog index/entry
curled on the preview; 471 pages carry exactly one tag, all `.md`
siblings 200 as `text/markdown`. The 11 misses are legacy blog slugs
whose HTML 308-redirects away (stale `MD_PAGES` entries predating this
PR, no head to tag; follow-up tracked in Linear)

Post-merge prod:
- [ ] Full llms.txt link sweep (every linked URL 200s; previews can't
cover the docs-hosted links)

## Linear

- fixes GROWTH-1013


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added Markdown alternate links across key product, pricing, blog, and
troubleshooting pages.
* Added Supabase Vector documentation covering features, use cases,
workflows, and technical details.
* Updated AI-focused documentation indexes with dedicated pricing
content.
  * Added redirects for updated Vector documentation URLs.

* **Tests**
* Added coverage to verify Markdown documentation links stay aligned
with available pages.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants