connectrpc / connect-go

The Go implementation of Connect: Protobuf RPC that works.
https://connectrpc.com
Apache License 2.0
2.76k stars 90 forks source link

Use "unimplemented" code for cardinality violations #712

Closed jhump closed 3 months ago

jhump commented 3 months ago

The table in the docs for gRPC status codes indicates that a "cardinality violation" -- when a stream is expected to have exactly one message and instead has zero or multiple -- should result in an "unimplemented" error code, both from clients upon observing a malformed response stream and from servers upon observing a malformed request stream.

This library was previously using "unknown" as the error code, fashioned after grpc-go, which apparently does not correctly implement this. Further, this library only validated the response stream, in the client. With this change, it uses the correct code and also validates the request stream, in the server.