runar-rkmedia / gotally

0 stars 1 forks source link

unhandled errors are invalid wire-format for protobuf #12

Open runar-rkmedia opened 1 year ago

runar-rkmedia commented 1 year ago

There is a custom catcher for unhandled errors. It works only with json at the current time. Look into if it is possible for buf-connect to handle those cases instead of this custom formatter.

The error can be reproduced by using the go-connect-client, for instance in a test, and then panicing the code, or having the middleware return an error to the user. This produces an error like:

New Game failed invalid_argument: unmarshal into *tallyv1.NewGameResponse: proto: cannot parse invalid wire-format data

The reason this is happening is my fault, as I was not following the documentation when writing the middlewares, which uses only the stock-http-handlers. These do not take into account any connect/grpc-specific errors, but only returns json.

Although my frontend code handles this already (by accident), it is terrible to break the contract this way. Any stricter client would probably break badly.