Skip to content

Improve Status formatting#2403

Merged
LucioFranco merged 2 commits into
grpc:masterfrom
rerun-io:emilk/improve-status-error-message
Aug 26, 2025
Merged

Improve Status formatting#2403
LucioFranco merged 2 commits into
grpc:masterfrom
rerun-io:emilk/improve-status-error-message

Conversation

@emilk
Copy link
Copy Markdown
Contributor

@emilk emilk commented Aug 26, 2025

Motivation

The Status struct is the canonical error message in tonic. Printing it currently prints out a very verbose and difficult-to-read message.

Solution

Improve impl, Display for status by:

  • Only printing the message if it is non-empty
  • Only printing the metadata if it is non-empty`
  • Always omitting the binary details (printing out details: [22, 51, 50, 48, 51, 53, 98, 57, 50, 55, 50, 55, 100, 54, 101, …] is not helping anyone)

Copy link
Copy Markdown
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

LGTM, one small nit but otherwise I think this is a positive change.

Comment thread tonic/src/status.rs Outdated
Comment on lines +756 to +759
// Binary data - not useful to human eyes.
// if !self.details().is_empty() {
// write!(f, ", details: {:?}", self.details())?;
// }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we def want this in debug, display I think is fine to skip so I think we can just remove this whole block?

Comment thread tonic/src/status.rs Outdated
@LucioFranco LucioFranco merged commit 52f9de8 into grpc:master Aug 26, 2025
20 checks passed
xumaple pushed a commit to xumaple/tonic that referenced this pull request Aug 29, 2025
## Motivation
The `Status` struct is the canonical error message in `tonic`. Printing
it currently prints out a very verbose and difficult-to-read message.

## Solution
Improve `impl, Display for status` by:

* Only printing the `message` if it is non-empty
* Only printing the `metadata` if it is non-empty`
* Always omitting the binary `details` (printing out `details: [22, 51,
50, 48, 51, 53, 98, 57, 50, 55, 50, 55, 100, 54, 101, …]` is not helping
anyone)
Comment thread tonic/src/status.rs
write!(f, "status: '{}'", self.code())?;

if !self.message().is_empty() {
write!(f, ", self: {:?}", self.message())?;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@LucioFranco should this be

Suggested change
write!(f, ", self: {:?}", self.message())?;
write!(f, ", message: {:?}", self.message())?;

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤦

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

tottoto pushed a commit that referenced this pull request Sep 20, 2025
* Follow-up to #2403

I accidentally used confusing labels. Thanks to @kloakin for pointing it
out.
@bobrik
Copy link
Copy Markdown
Contributor

bobrik commented Oct 29, 2025

A follow-up to this: #2417

alexanderrilee pushed a commit to alexanderrilee/tonic that referenced this pull request Oct 29, 2025
* Follow-up to grpc#2403

I accidentally used confusing labels. Thanks to @kloakin for pointing it
out.
jen20 pushed a commit to jen20/tonic that referenced this pull request Dec 30, 2025
* Follow-up to grpc#2403

I accidentally used confusing labels. Thanks to @kloakin for pointing it
out.
grembo pushed a commit to grembo/tonic that referenced this pull request Feb 3, 2026
* Follow-up to grpc#2403

I accidentally used confusing labels. Thanks to @kloakin for pointing it
out.
LucioFranco pushed a commit that referenced this pull request Feb 13, 2026
* Follow-up to #2403

I accidentally used confusing labels. Thanks to @kloakin for pointing it
out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants