fix(start-server-core): return 406 instead of 500 for non-HTML Accept headers - #7925
fix(start-server-core): return 406 instead of 500 for non-HTML Accept headers#7925okxint wants to merge 2 commits into
Conversation
… headers When a request's Accept header doesn't include HTML or */*, the handler correctly rejects it but was returning HTTP 500 (Server Error). Failed content negotiation is a client-side condition; HTTP 406 Not Acceptable is the correct status code for this case. Fixes TanStack#7913
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe change escapes single quotes in generated dynamic imports for two code-splitting strategies and changes unsupported HTML request responses from HTTP 500 to HTTP 406. ChangesCode-split import generation
HTTP content negotiation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
| ) { | ||
| programPath.unshiftContainer('body', [ | ||
| template.statement( | ||
| `const ${splitNodeMeta.localImporterIdent} = () => import('${splitUrl}')`, |
There was a problem hiding this comment.
this file should not be changed in this PR
| return normalizeSsrResponse( | ||
| Response.json( | ||
| { error: 'Only HTML requests are supported here' }, | ||
| { status: 500 }, |
There was a problem hiding this comment.
we should add an e2e test
Problem
When a request's
Acceptheader doesn't include HTML or*/*,createStartHandlercorrectly rejects it but returnsHTTP 500 Internal Server Error. This is wrong — the problem is with the request, not the server.Fix
Return
HTTP 406 Not Acceptable, which is what the HTTP spec defines for failed content negotiation.Fixes #7913
Summary by CodeRabbit
406 Not Acceptableresponse instead of a server error.