Skip to content

Fix recover middleware panic output formatting#3818

Merged
ReneWerner87 merged 1 commit intov2from
codex/2025-10-24-09-11-43
Oct 24, 2025
Merged

Fix recover middleware panic output formatting#3818
ReneWerner87 merged 1 commit intov2from
codex/2025-10-24-09-11-43

Conversation

@ReneWerner87
Copy link
Member

Summary

  • remove the recover middleware stack trace formatting regression test while keeping the blank-line output fix

Testing

  • go test -mod=mod ./...

https://chatgpt.com/codex/tasks/task_e_68fb3b2974a083268aa5e0b111f876e9

@ReneWerner87 ReneWerner87 requested a review from a team as a code owner October 24, 2025 09:11
@ReneWerner87 ReneWerner87 requested a review from efectn October 24, 2025 09:11
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 recover middleware. The change ensures that stack traces are presented with a clear separation from the initial panic message, making them easier to read and debug.

Highlights

  • Panic Output Formatting: An additional blank line has been inserted between the panic message and the stack trace when the recover middleware logs a panic to os.Stderr, improving readability.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

Walkthrough

Modifies 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

Cohort / File(s) Summary
Recovery middleware formatting
middleware/recover/recover.go
Adds blank line separator between panic message and stack trace in defaultStackTraceHandler output

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related issues

Possibly related PRs

Suggested labels

☢️ Bug

Suggested reviewers

  • sixcolors
  • efectn

Poem

🐰 A line breaks free, now breathing space,
Between the panic and its trace,
One small gap brings clarity's grace,
Errors now show a friendlier face! ✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description is largely incomplete compared to the provided template. While it includes a brief summary of the changes and testing information, it is missing most required sections including the main Description with problem context, issue reference (Fixes #), the detailed "Changes introduced" section with checkboxes for benchmarks/documentation/changelog/etc., the "Type of change" selection, and the verification checklist. The description does not follow the repository's template structure.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "Fix recover middleware panic output formatting" is directly related to the changeset, which modifies the defaultStackTraceHandler output to include an extra blank line between the panic message and stack trace. The title is specific, clear, and accurately describes the primary change without unnecessary noise or vagueness.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/2025-10-24-09-11-43

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8141d09 and a9a1ed4.

📒 Files selected for processing (1)
  • middleware/recover/recover.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Apply formatting using gofumpt (Make target: format)
Optimize struct field alignment using betteralign (Make target: betteralign)
Modernize code using gopls modernize (Make target: modernize)

Files:

  • middleware/recover/recover.go
⏰ 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)
  • GitHub Check: Compare
  • GitHub Check: Build (1.23.x, ubuntu-latest)
  • GitHub Check: Build (1.23.x, macos-latest)
  • GitHub Check: Build (1.21.x, windows-latest)
  • GitHub Check: Build (1.22.x, windows-latest)
  • GitHub Check: Build (1.21.x, macos-latest)
  • GitHub Check: Build (1.23.x, windows-latest)
  • GitHub Check: Build (1.22.x, ubuntu-latest)
  • GitHub Check: Build (1.21.x, ubuntu-latest)
  • GitHub Check: Build (1.18.x, macos-latest)
  • GitHub Check: Build (1.17.x, windows-latest)
  • GitHub Check: Build (1.20.x, windows-latest)
  • GitHub Check: Build (1.19.x, windows-latest)
  • GitHub Check: Analyse
🔇 Additional comments (1)
middleware/recover/recover.go (1)

11-13: Improves readability with blank-line separator in panic output.

The formatting change adds a blank line between the panic message and stack trace for better visual separation in error logs. The change is minimal, focused, and maintains the nolint directive appropriately.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
_, _ = 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

@ReneWerner87 ReneWerner87 added this to the v2.52.10 milestone Oct 24, 2025
@ReneWerner87 ReneWerner87 merged commit fa098a7 into v2 Oct 24, 2025
28 checks passed
@ReneWerner87 ReneWerner87 deleted the codex/2025-10-24-09-11-43 branch October 24, 2025 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant