Skip to content

feat(grpc): introduce Status and ServerStatus types#2454

Merged
sauravzg merged 2 commits intohyperium:masterfrom
sauravzg:grpc_status
Dec 24, 2025
Merged

feat(grpc): introduce Status and ServerStatus types#2454
sauravzg merged 2 commits intohyperium:masterfrom
sauravzg:grpc_status

Conversation

@sauravzg
Copy link
Collaborator

Introduces the foundational Status and ServerStatus types for gRPC status handling.

  • Status: Represents a standard gRPC status with a code and message.
  • ServerStatus: A wrapper around Status designed to prevent accidental leakage of sensitive server errors to the client. This type distinction ensures that handlers must explicitly convert to Status, encouraging a conscious decision about what information is exposed.
  • StatusCode: Enum representing standard gRPC status codes.

This implementation provides the necessary types to unblock server-side API development without relying on a heavy tonic::Status. This is not meant to be an intermediate or final Status implementation but serves as a way to implement functional requirements while we design the final Status.

Copy link

@darth-raijin darth-raijin left a comment

Choose a reason for hiding this comment

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

I left one suggestion on the tests about avoiding duplication of the "ok" message by assigning it to a variable and reusing it in the assertions. It should make the test a bit less brittle if the message ever changes.

Introduces the foundational `Status` and `ServerStatus` types for gRPC status handling.

* `Status`: Represents a standard gRPC status with a code and message.
* `ServerStatus`: A wrapper around `Status` designed to prevent accidental leakage of sensitive server errors to the client. This type distinction ensures that handlers must explicitly convert to `Status`, encouraging a conscious decision about what information is exposed.
* `StatusCode`: Enum representing standard gRPC status codes.

This implementation provides the necessary types to unblock server-side API development. This is not meant to be an intermediate or final Status implementation but serves as a way to implement functional requirements while we design the final `Status`.
Copy link
Collaborator

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

This is fine, but I do think we should strongly consider aligning a little more with the internal design for Status, particularly having a StatusError type that can't represent OK, and a Status that is Result<(), StatusError> for now. That might help prevent future misconceptions/etc.

@sauravzg
Copy link
Collaborator Author

Noted. I have unfortunately progressed a lot on my branch. So, I'll take it as a todo and migrate all code to use a Status like approach in a future change.

@sauravzg sauravzg merged commit 88a448a into hyperium:master Dec 24, 2025
20 checks passed
jen20 pushed a commit to jen20/tonic that referenced this pull request Dec 30, 2025
Introduces the foundational `Status` and `ServerStatus` types for gRPC
status handling.

* `Status`: Represents a standard gRPC status with a code and message.
* `ServerStatus`: A wrapper around `Status` designed to prevent
accidental leakage of sensitive server errors to the client. This type
distinction ensures that handlers must explicitly convert to `Status`,
encouraging a conscious decision about what information is exposed.
* `StatusCode`: Enum representing standard gRPC status codes.

**This implementation provides the necessary types to unblock
server-side API development without relying on a heavy `tonic::Status`.
This is not meant to be an intermediate or final Status implementation
but serves as a way to implement functional requirements while we design
the final `Status`.**
grembo pushed a commit to grembo/tonic that referenced this pull request Feb 3, 2026
Introduces the foundational `Status` and `ServerStatus` types for gRPC
status handling.

* `Status`: Represents a standard gRPC status with a code and message.
* `ServerStatus`: A wrapper around `Status` designed to prevent
accidental leakage of sensitive server errors to the client. This type
distinction ensures that handlers must explicitly convert to `Status`,
encouraging a conscious decision about what information is exposed.
* `StatusCode`: Enum representing standard gRPC status codes.

**This implementation provides the necessary types to unblock
server-side API development without relying on a heavy `tonic::Status`.
This is not meant to be an intermediate or final Status implementation
but serves as a way to implement functional requirements while we design
the final `Status`.**
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.

3 participants