Skip to content

Update BadRequest.FieldViolation richer error type #2244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
MathieuTricoire opened this issue Apr 4, 2025 · 0 comments
Open

Update BadRequest.FieldViolation richer error type #2244

MathieuTricoire opened this issue Apr 4, 2025 · 0 comments

Comments

@MathieuTricoire
Copy link

Feature Request

Crates

tonic-types

Motivation

Google has updated the google.rpc.BadRequest.FieldViolation message in its error model by adding two new fields: string reason and LocalizedMessage localized_message. This feature request proposes reflecting this upstream change in the tonic-types crate.

Reference:
https://github.com/googleapis/googleapis/blob/a31d216ae702a184b5b00bdece3775177dfb2cf7/google/rpc/error_details.proto#L216-L226

Proposal

  • Update the .proto files to the latest version.

  • Extend the FieldViolation struct to include two new fields:

    • pub reason: String
    • pub localized_message: Option<LocalizedMessage>
  • Update the following functions to accept two additional parameters (reason: impl Into<String> and loc_message: Option<LocalizedMessage>):

    • FieldViolation::new
    • ErrorDetails::with_bad_request_violation
    • ErrorDetails::add_bad_request_violation
    • BadRequest::add_violation

This proposal would involve modifying existing functions and therefore introduces a breaking change.

Alternatives

This is an initial proposal, and I would like to open the discussion to consider a non-breaking alternative.

Instead of modifying existing functions, we could add new functions to support the new fields. In that case, I’d appreciate input on appropriate naming conventions.

I’m happy to contribute the implementation once a direction is agreed upon. I already have a branch prepared for the breaking-change version, if you'd like to review it to get a sense of the scope 86d1095

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

No branches or pull requests

1 participant