grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.45k stars 760 forks source link

Cardinality violations should use error code “unimplemented” #1429

Open jhump opened 1 month ago

jhump commented 1 month ago

The gRPC docs for error codes state that both client and server should use the unimplemented code for cardinality violations. See table at the bottom of this doc (you can search for “cardinality violation” in the doc): https://grpc.github.io/grpc/core/md_doc_statuscodes.html.

A cardinality violation is when a response stream contains an incorrect number of messages. Specifically, when the response stream for a unary RPC contains zero messages with an OK status or more than one message. (The same goes for client-stream RPCs, which also expect a unary response, but this package does not support client-streaming.)

The client in this package returns an unknown error in this situation instead of unimplemented.

ejona86 commented 1 month ago

For the Java issue I mentioned this change to the spec was made without any real notification/discussion. So we may want to re-consider the spec in this case. https://github.com/grpc/grpc-java/issues/11247#issuecomment-2140803584

sampajano commented 1 month ago

Thanks for reporting the issue, and thanks @ejona86 for clarifying!

I'm happy to make the changes on the grpc-web side once we reached conclusion on how other languages would be aligned (or the spec would be updated), per https://github.com/grpc/grpc-java/issues/11247#issuecomment-2140803584.