Fix recover middleware panic output formatting#3818
Conversation
Summary of ChangesHello @ReneWerner87, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue with the output formatting of panic messages within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
WalkthroughModifies the recovery middleware's default stack trace handler to add an extra blank line between the panic message and the stack trace output for improved error readability. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.go📄 CodeRabbit inference engine (AGENTS.md)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
🔇 Additional comments (1)
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.
Code Review
This pull request adds a blank line to the panic output for better readability. The change is correct and achieves its goal. I've suggested a small improvement to use fmt.Fprintf directly, which is more idiomatic and slightly more performant as it avoids an intermediate string allocation.
|
|
||
| func defaultStackTraceHandler(_ *fiber.Ctx, e interface{}) { | ||
| _, _ = os.Stderr.WriteString(fmt.Sprintf("panic: %v\n%s\n", e, debug.Stack())) //nolint:errcheck // This will never fail | ||
| _, _ = os.Stderr.WriteString(fmt.Sprintf("panic: %v\n\n%s\n", e, debug.Stack())) //nolint:errcheck // This will never fail |
There was a problem hiding this comment.
For better performance and to follow idiomatic Go, consider using fmt.Fprintf to write directly to os.Stderr. This avoids creating an intermediate string with fmt.Sprintf and then writing it, thus preventing an unnecessary memory allocation.
| _, _ = os.Stderr.WriteString(fmt.Sprintf("panic: %v\n\n%s\n", e, debug.Stack())) //nolint:errcheck // This will never fail | |
| _, _ = fmt.Fprintf(os.Stderr, "panic: %v\n\n%s\n", e, debug.Stack()) //nolint:errcheck // This will never fail |
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68fb3b2974a083268aa5e0b111f876e9