feature: do not raise 500's on bad request#255
Conversation
Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis PR refactors HTTP request error handling by introducing an error classification system that wraps errors with explicit HTTP status codes, applies it to request body parsing, simplifies error response handlers, and validates behavior with new regression tests. ChangesRequest Error Classification and Response
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Pull request overview
This PR updates the HTTP request parsing/error-handling flow so malformed client input returns 4xx (not 5xx), while preserving 413 for request-size overflows and keeping true internal failures on the internal-error path.
Changes:
- Introduced a
statusErrorwrapper +classifyParseErrhelper to carry explicit HTTP status codes (notably 413) through error chains. - Adjusted request parsing to classify
ParseMultipartForm/io.ReadAlloverflow errors as 413 and otherwise default parsing failures to 400. - Updated and added tests to cover regression cases (oversize non-multipart body, malformed query in multipart) and the updated internal error response behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/http_plugin_test.go | Updates expected error body for oversize request handling. |
| tests/handler_test.go | Adds regression tests for 413 on oversize non-multipart bodies and 400 on malformed multipart query parsing. |
| handler/status_error.go | Adds statusError, withStatus, and classifyParseErr to preserve explicit status codes for parse errors. |
| handler/status_error_test.go | Unit tests for statusError wrapping and classifyParseErr promotion behavior. |
| handler/request.go | Routes multipart parse errors and raw-body read errors through classifyParseErr. |
| handler/handler.go | Makes request-parse errors default to 400 (unless explicitly wrapped) and updates internal error response writing behavior. |
| handler/handle_error_test.go | Verifies handleError writes a body and expected headers in debug and non-debug modes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reason for This PR
closes: roadrunner-server/roadrunner#2353
Description of Changes
License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the MIT license.
PR Checklist
[Author TODO: Meet these criteria.][Reviewer TODO: Verify that these criteria are met. Request changes if not]git commit -s).CHANGELOG.md.Summary by CodeRabbit
Bug Fixes
Tests