Test that implementations reject a stream body cut off partway through a message

Open
#1,141 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
go, grpc
Domain
api, testing-qa

Research direction

Start with the existing raw request and response support in the Connect, gRPC, and gRPC-Web suites, then review the incomplete-message and incomplete-message-prefix cases described in the issue. Add the four truncation cases for each applicable direction and the Connect data-after-end-stream case, then run the suites and verify the expected invalid-argument or internal codes and the grpcclient-known-failing.txt, grpcserver-known-failing.txt, and grpcserver-web-known-failing.txt results.

Written by the indexing model from the issue text.

Description

The Connect, gRPC, and gRPC-Web unexpected request and response suites cover messages with bad flags, codecs, and compression, and #1104 added a response that ends without the Connect end-stream message. No case covers a body that ends partway through an enveloped message, in either direction, or a Connect response with data after its end-stream message. An implementation that stops reading at the end of the body and drops its partial buffer reports these as complete streams, which is indistinguishable from success. connect-py did this for both requests and responses (connectrpc/connect-py#359), and the current suites pass either way.

I have the cases below on a branch: https://github.com/connectrpc/conformance/compare/main...stefanvanburen:conformance:svanburen/incomplete-request-body

Cases

Each direction gets two cases, built with the existing raw request and response support:

  • incomplete-message: a stream item whose prefix promises 10 bytes and whose payload is 3 bytes, using StreamItem.length.
  • incomplete-message-prefix: a raw body that ends 3 bytes into a 5-byte prefix.

Server suites (Connect, gRPC, gRPC-Web) send these as a ClientStream request. Client suites (Connect, gRPC) send them as a ServerStream response after one complete message. gRPC-Web clients are left out, since a gRPC-Web body cut off mid-message also has no trailers frame, which trailers-in-body/missing-status already covers. The Connect client suite also gets server-stream/data-after-end-stream: a message, the end-stream message, then another message.

Expected codes

The truncation cases expect CODE_INVALID_ARGUMENT, and data-after-end-stream expects CODE_INTERNAL, which is what connect-go returns ("protocol error: promised N bytes in enveloped message, got M bytes", "protocol error: incomplete envelope: unexpected EOF", and "corrupt response: N extra bytes after end of stream"). For gRPC and gRPC-Web, CODE_INTERNAL is also allowed, since the gRPC spec doesn't name a code and grpc-go uses internal.

Results on the branch

  • Reference server: 24 of 24 variants pass. Reference client: 19 of 19 pass.
  • grpc-go, client and server: incomplete-message passes with internal. incomplete-message-prefix fails: grpc-go treats a body that ends mid-prefix as complete and reports success. The branch lists those cases in grpcclient-known-failing.txt, grpcserver-known-failing.txt, and grpcserver-web-known-failing.txt.

Happy to open a PR from the branch if this looks right.

Dominant language
Go
Stars
96
Forks
22
Avg merge
1d 9h
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from connectrpc/conformance

All issues in connectrpc/conformance

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.