Skip to content

🐛 bug: Fix recover middleware panic output formatting#3816

Merged
ReneWerner87 merged 1 commit intomainfrom
fix-reported-bug-in-main-branch
Oct 24, 2025
Merged

🐛 bug: Fix recover middleware panic output formatting#3816
ReneWerner87 merged 1 commit intomainfrom
fix-reported-bug-in-main-branch

Conversation

@gaby
Copy link
Member

@gaby gaby commented Oct 24, 2025

Summary

  • add the missing blank line between the panic header and stack trace in the recover middleware output so it matches Go's native panic format

Fixes #3815


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

@gaby gaby requested a review from a team as a code owner October 24, 2025 07:22
Copilot AI review requested due to automatic review settings October 24, 2025 07:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the formatting of panic output in the recover middleware to match Go's native panic format by adding a blank line between the panic message and stack trace.

  • Modified the defaultStackTraceHandler function to include an additional newline character in the format string

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @gaby, 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 refines the output formatting of the recover middleware to align with Go's standard panic messages. By introducing a blank line between the panic header and the stack trace, the change enhances the clarity and familiarity of error logs, making them easier for developers to interpret and debug. This is a small but impactful improvement to the developer experience.

Highlights

  • Panic Output Formatting: The pull request addresses an inconsistency in the recover middleware's panic output by adding a missing blank line.
  • Go Native Format Alignment: The change ensures that the panic output generated by the middleware now precisely matches Go's native panic format, improving readability and consistency.
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

The change modifies panic output formatting in the recovery middleware by inserting an additional blank line between the panic header and the stack trace in the defaultStackTraceHandler function.

Changes

Cohort / File(s) Summary
Panic Output Formatting
middleware/recover/recover.go
Inserts an extra blank line between the panic header and stack trace in panic output

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related issues

Poem

A rabbit hops through logs so bright,
With spacing now just right—
A blank line added, clean and neat,
Makes errors quite a treat! 🐰✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description is substantially incomplete relative to the template requirements. While it includes a brief summary and correctly references the issue (Fixes #3815), it is missing nearly all of the required template sections including "Changes introduced" with detailed checkboxes, "Type of change" selection, and the comprehensive "Checklist" items. The description lacks structured detail on aspects like documentation updates, testing confirmation, benchmarks, and other checklist items that the template explicitly requires authors to address. For a bug fix of this scope, this minimal description does not adequately follow the repository's contribution guidelines.
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 "🐛 bug: Fix recover middleware panic output formatting" is directly related to the main change in the PR. The title clearly identifies the component (recover middleware), the type of change (fix for a bug), and the specific aspect being addressed (panic output formatting). This matches the actual change described in the raw summary, which shows that the defaultStackTraceHandler now inserts a blank line between the panic header and stack trace. While the emoji and "bug:" prefix are somewhat stylistic, the core title text is clear, specific, and sufficiently descriptive for someone scanning history to understand the primary change.
✨ 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 fix-reported-bug-in-main-branch

📜 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 534aa88 and cec156c.

📒 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). (1)
  • GitHub Check: unit (1.25.x, windows-latest)
🔇 Additional comments (1)
middleware/recover/recover.go (1)

11-13: Change is safe and correct. All tests pass with no output format dependencies.

The tests in recover_test.go validate error messages, status codes, and middleware logic—they do not parse or assert on the panic output format written to stderr. The format change from "panic: %v\n%s\n" to "panic: %v\n\n%s\n" correctly adds a blank line between the panic header and stack trace, matching Go's native panic format, with no breaking changes detected in the codebase.


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.

@gaby gaby changed the title Fix recover middleware panic output formatting 🐛 bug: Fix recover middleware panic output formatting Oct 24, 2025
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

The pull request adds a blank line between the panic header and stack trace in the recover middleware output to match Go's native panic format. This change improves the readability of panic outputs. I have added a review comment to address a critical issue.

@ReneWerner87 ReneWerner87 added this to v3 Oct 24, 2025
@ReneWerner87 ReneWerner87 added this to the v3 milestone Oct 24, 2025
@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.16%. Comparing base (534aa88) to head (cec156c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3816      +/-   ##
==========================================
+ Coverage   91.91%   92.16%   +0.25%     
==========================================
  Files         115      115              
  Lines       12377     9662    -2715     
==========================================
- Hits        11376     8905    -2471     
+ Misses        729      485     -244     
  Partials      272      272              
Flag Coverage Δ
unittests 92.16% <100.00%> (+0.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ReneWerner87 ReneWerner87 merged commit 9f7836e into main Oct 24, 2025
16 checks passed
@github-project-automation github-project-automation bot moved this to Done in v3 Oct 24, 2025
@ReneWerner87 ReneWerner87 deleted the fix-reported-bug-in-main-branch branch October 24, 2025 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

🐛 [Bug]: middleware/recover missing extra \n cause log parser to mismatch stacktrace

3 participants