grpc-go icon indicating copy to clipboard operation
grpc-go copied to clipboard

transport: add status details even when aborting early

Open joybestourous opened this issue 4 months ago • 1 comments

Modifies earlyAbortStreamHandler to include status details if present.

Most use cases of earlyAbortStreamHandler are for circumstances where there are certainly no error details (bad HTTP methods, bad content-type, internal error, etc). However, tap handlers also typically go through the earlyAbortStreamHandler. In http2_server.go:

	if t.inTapHandle != nil {
		var err error
		if s.ctx, err = t.inTapHandle(s.ctx, &tap.Info{FullMethodName: s.method, Header: mdata}); err != nil {
			t.mu.Unlock()
			if t.logger.V(logLevel) {
				t.logger.Infof("Aborting the stream early due to InTapHandle failure: %v", err)
			}
			stat, ok := status.FromError(err)
			if !ok {
				stat = status.New(codes.PermissionDenied, err.Error())
			}
			t.controlBuf.put(&earlyAbortStream{
				// ...
				status:         stat,  // <-- CAN have details!
			})

Yet the handler does not include error details by default, limiting how tap handlers can be used and breaking some user assumptions surrounding which information is propagated. This PR fixes this by checking for status details and including the header for them if present.

RELEASE NOTES:

  • transport: status details from tap handler errors are now propagated

joybestourous avatar Dec 08 '25 19:12 joybestourous

Codecov Report

:x: Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 83.14%. Comparing base (f9d2bdb) to head (82b787d). :warning: Report is 13 commits behind head on master.

Files with missing lines Patch % Lines
internal/transport/controlbuf.go 42.85% 2 Missing and 2 partials :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8754      +/-   ##
==========================================
- Coverage   83.35%   83.14%   -0.22%     
==========================================
  Files         418      418              
  Lines       32377    32513     +136     
==========================================
+ Hits        26989    27033      +44     
+ Misses       4022     4014       -8     
- Partials     1366     1466     +100     
Files with missing lines Coverage Δ
internal/transport/controlbuf.go 65.56% <42.85%> (-22.71%) :arrow_down:

... and 35 files with indirect coverage changes

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

codecov[bot] avatar Dec 08 '25 19:12 codecov[bot]