[codex] fix markdown accept negotiation#142
Conversation
Deploying qf-api-docs with
|
| Latest commit: |
debf726
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6521ef7a.qf-api-docs.pages.dev |
| Branch Preview URL: | https://codex-fix-markdown-accept-ne.qf-api-docs.pages.dev |
There was a problem hiding this comment.
Pull request overview
Updates the docs edge middleware to perform standards-based Accept content negotiation between HTML and Markdown, ensuring clients receive the best supported representation (or a correct 406 Not Acceptable when none are acceptable).
Changes:
- Replace the previous “mentions
text/markdown” boolean check with ranked negotiation honoringqvalues and wildcards. - Add a
406 Not Acceptableresponse path when both HTML and Markdown are rejected. - Add regression tests covering ranking behavior, HTML-preferred requests, and unsupported-only
Acceptheaders.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/markdown-negotiation-shared.cjs |
Adds parsing + ranking helpers for Accept negotiation across supported media types. |
src/markdown-negotiation-runtime.cjs |
Uses ranked negotiation to choose HTML vs Markdown, and returns 406 when neither is acceptable. |
tests/markdown-negotiation.test.cjs |
Adds regression tests for ranking, HTML preference via q, and 406 behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e5ecd23c55
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
What changed
Acceptnegotiation betweentext/htmlandtext/markdownqvalues andq=0when ranking supported representations406 Not Acceptableonly when the client rejects both HTML and MarkdownAcceptheadersWhy this changed
The docs site was scoring
75/100on acceptmarkdown.com because it always served Markdown whenevertext/markdownappeared anywhere in theAcceptheader, even when HTML had a higher preference, and it silently fell back to HTML for unsupported types instead of returning406.Impact
Acceptheaders now get a standards-correct406response instead of a silent HTML fallbackRoot cause
The edge middleware only answered ?does this request mention
text/markdownwithq > 0?? rather than performing best-match content negotiation across the representations the site can actually serve.Validation
NODE_PATH=C:\Code\qf-api-docs\node_modules C:\Users\Basit\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\bin\node.exe --test tests\markdown-negotiation.test.cjsNODE_PATH=C:\Code\qf-api-docs\node_modules C:\Users\Basit\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\bin\node.exe --test tests\*.test.cjs