fix(adapter): improve error propagation in Express-style handler#4250
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThe Express-style three-parameter handler adapter ( ChangesExpress Handler Error Propagation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.11.4)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" 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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes error propagation for Express-style handlers adapted through toFiberHandler, ensuring Fiber returns the handler's own error when both the handler and next() fail. It keeps adapter behavior consistent with the other Express-style adapter variants.
Changes:
- Update the
func(Req, Res, func() error) erroradapter path to capturenext()errors separately and only return them when the handler itself returnsnil. - Add regression tests covering handler-error precedence over
next()errors. - Add regression tests covering propagation of
next()errors when the handler returnsnil.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
adapter.go |
Adjusts Express-style adapter error propagation for the error-returning next variant. |
adapter_test.go |
Adds tests validating handler-vs-next error precedence and next error propagation. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4250 +/- ##
==========================================
+ Coverage 91.20% 91.25% +0.05%
==========================================
Files 127 127
Lines 12551 12556 +5
==========================================
+ Hits 11447 11458 +11
+ Misses 692 687 -5
+ Partials 412 411 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request modifies the adaptExpressHandler function in adapter.go to correctly handle error propagation for Express-style handlers. It ensures that errors from the next callback are returned if the handler itself returns nil, while prioritizing errors returned by the handler if both occur. Two new test cases have been added to adapter_test.go to validate these scenarios. I have no feedback to provide.
No description provided.