Skip to content

Cardinality violations in Client streaming RPC. #8278

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
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Pranjali-2501
Copy link

Client should ensure an "Internal" error is returned for client-streaming RPCs if the server doesn't send a message before returning status OK.
Currently it is returning "EOF", which should not be the case for cardinality violations.

Copy link

CLA Not Signed

Copy link

codecov bot commented Apr 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.25%. Comparing base (399e2d0) to head (f06ff56).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8278      +/-   ##
==========================================
- Coverage   82.29%   82.25%   -0.05%     
==========================================
  Files         417      417              
  Lines       41356    41362       +6     
==========================================
- Hits        34035    34022      -13     
- Misses       5907     5922      +15     
- Partials     1414     1418       +4     
Files with missing lines Coverage Δ
stream.go 81.64% <100.00%> (+0.09%) ⬆️

... and 21 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -542,6 +542,8 @@ type clientStream struct {

sentLast bool // sent an end stream

recvMsg bool // received msg from server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Boolean field names should be like questions with yes/no answers, example "didReceiveFirstMessage".

@@ -1134,11 +1136,17 @@ func (a *csAttempt) recvMsg(m any, payInfo *payloadInfo) (err error) {
if statusErr := a.transportStream.Status().Err(); statusErr != nil {
return statusErr
}
if cs.desc.ClientStreams && !cs.desc.ServerStreams && !cs.recvMsg{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we leave out cs.desc.ClientStreams from this check? I would assume that the server needs to send a message for unary RPCs also. Are unary RPCs handled by this code path? If yes, we should add a test for unary RPCs also.

return io.EOF // indicates successful end of stream.
}

return toRPCErr(err)
}
if cs.desc.ClientStreams {
cs.recvMsg = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set this boolean without the check? Otherwise we would need to document the variable in a way to make it obvious that this is set only for client streaming RPCs. Even then users may accidentally use it for other types of RPCs.

@@ -1134,11 +1136,17 @@ func (a *csAttempt) recvMsg(m any, payInfo *payloadInfo) (err error) {
if statusErr := a.transportStream.Status().Err(); statusErr != nil {
return statusErr
}
if cs.desc.ClientStreams && !cs.desc.ServerStreams && !cs.recvMsg{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vet checks is failing, probably because of the missing space before {. Can you please fix the vet issues?

@arjan-bal
Copy link
Contributor

Do we need a similar check on the server side also, i.e. change the status to internal if the server attempts to close without writing a message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants