🐛 Fixed members-only 403 leaking when llms.txt is disabled#28260
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe PR reorders the entry controller's 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
The `.md` markdown routes are registered unconditionally, so the entry controller relies on a runtime check to gate the llms.txt feature. That check ran in the wrong order: the members-only 403 for non-public posts was returned *before* the `llmsService.isEnabled()` check. As a result, requesting a paid/members post's `.md` URL returned a feature-specific `403 text/markdown` response even when the `llmsTxt` labs flag was disabled, leaking llms.txt behaviour (and revealing a post's existence/visibility) when the feature should be fully off. Moved the `isEnabled()` check ahead of the visibility check so a disabled feature always falls back to a 302 redirect to the canonical URL — the same graceful degradation already used for public `.md` requests — regardless of post visibility. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
506b6cc to
e66ac6d
Compare
Ref
Follow-up to the
llms.txtwork (labs flagllmsTxt).Problem
The per-post
.mdmarkdown routes (/:slug.md) are registered unconditionally in the static-pages and collection routers, so the entry controller relies on a runtime check to gate the feature. That check ran in the wrong order — the members-only403for non-public posts was returned before thellmsService.isEnabled()check:So with the
llmsTxtlabs flag off, requesting a paid/members post's.mdURL still returned a feature-specific403 text/markdown"Members-only content" body — leaking llms.txt behaviour (and revealing a post's existence/visibility) when the feature is supposed to be fully disabled.This was found while verifying that nothing in the feature works with the flag off. Everything else gated correctly (
/llms.txt→ 302 redirect,Accept: text/markdowncontent negotiation → normal HTML, discovery headers absent); only non-public.mdrequests leaked..md.md.mdFix
Move the
isEnabled()check ahead of the visibility check, so a disabled feature always falls back to the canonical 302 redirect — the same graceful degradation already used for public.mdrequests — regardless of visibility. The members-only 403 is preserved when the feature is enabled.Tests
Added a
markdown requests (llms.txt)block to the entry controller unit tests, including a regression test that fails on the old ordering:Verified live against a dev instance with the flag off: all
.mdrequests (public/paid/members) now 302-redirect to canonical, with no feature-specific 403.🤖 Generated with Claude Code