-
Notifications
You must be signed in to change notification settings - Fork 133
Description
Is your feature request related to a problem? Please describe.
My code is somehow constructing Protobuf messages that fail to encode: timestamppb.Timestamp values with second values larger than maxSecondsInDuration. That's on me - but the current tools for picking up the error is insufficient.
Reproduce:
- Create a
timestamppb.Timestampmessage withSecondsset to315576000001. - Return this message as part of a response.
- Call the endpoint in such a way that protojson encoding is used:
curl -H "content-type: application/json" -X POST --fail-with-body http://server/service/Endpoint curlfails:curl: (22) The requested URL returned error: 500 {"code":"internal","message":"marshal message: proto: google.protobuf.Timestamp: seconds out of range 315576000000"}- Observe that there's no way within interceptors or other user-available mechanisms to handle this error.
Describe the solution you'd like
From what I can observe the error is returned from h.implementation(ctx, connCloser) here:
Line 237 in d7c0966
| _ = connCloser.Close(h.implementation(ctx, connCloser)) |
It would be nice to provide some sort of hook for picking this up, so that I can for example log it. In this case it would be great to have access to the complete Protobuf message that failed marshalling. In my case I'm getting this error when marshalling a rather large message containing a few thousands timestamps, and it's hard to decipher which one is incorrectly constructed.