Skip to content

Commit e8e82dd

Browse files
committed
correcting status code to Unknown for missing grpc code
1 parent e816736 commit e8e82dd

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

internal/transport/http2_client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
14641464
recvCompress string
14651465
httpStatusErr string
14661466
// the code from the grpc-status header, if present
1467-
grpcStatusCode = codes.Internal
1467+
grpcStatusCode = codes.Unknown
14681468
// headerError is set if an error is encountered while parsing the headers
14691469
headerError string
14701470
httpStatus string
@@ -1485,7 +1485,7 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
14851485
case "grpc-status":
14861486
code, err := strconv.ParseInt(hf.Value, 10, 32)
14871487
if err != nil {
1488-
se := status.New(codes.Internal, fmt.Sprintf("transport: malformed grpc-status: %v", err))
1488+
se := status.New(codes.Unknown, fmt.Sprintf("transport: malformed grpc-status: %v", err))
14891489
t.closeStream(s, se.Err(), true, http2.ErrCodeProtocol, se, nil, endStream)
14901490
return
14911491
}

internal/transport/transport_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2681,7 +2681,7 @@ func (s) TestClientDecodeHeader(t *testing.T) {
26812681
},
26822682
},
26832683
wantStatus: status.New(
2684-
codes.Internal,
2684+
codes.Unknown,
26852685
"transport: malformed grpc-status: strconv.ParseInt: parsing \"xxxx\": invalid syntax",
26862686
),
26872687
},
@@ -2813,7 +2813,7 @@ func (s) TestClientDecodeTrailer(t *testing.T) {
28132813
},
28142814
},
28152815
wantEndStreamStatus: status.New(
2816-
codes.Internal,
2816+
codes.Unknown,
28172817
"transport: malformed grpc-status: strconv.ParseInt: parsing \"xxxx\": invalid syntax",
28182818
),
28192819
},
@@ -2824,7 +2824,7 @@ func (s) TestClientDecodeTrailer(t *testing.T) {
28242824
{Name: ":status", Value: "xxxx"},
28252825
},
28262826
},
2827-
wantEndStreamStatus: status.New(codes.Internal, ""),
2827+
wantEndStreamStatus: status.New(codes.Unknown, ""),
28282828
},
28292829
{
28302830
name: "http2_frame_size_exceeds",
@@ -2843,7 +2843,7 @@ func (s) TestClientDecodeTrailer(t *testing.T) {
28432843
{Name: "content-type", Value: "application/grpc"},
28442844
},
28452845
},
2846-
wantEndStreamStatus: status.New(codes.Internal, ""),
2846+
wantEndStreamStatus: status.New(codes.Unknown, ""),
28472847
},
28482848
{
28492849
name: "deadline_exceeded_status",

test/http_header_end2end_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (s) TestHTTPHeaderFrameErrorHandlingInitialHeader(t *testing.T) {
116116
"content-type", "application/grpc",
117117
"grpc-status", "abc",
118118
},
119-
errCode: codes.Internal,
119+
errCode: codes.Unknown,
120120
},
121121
{
122122
name: "Malformed grpc-tags-bin field ignores http status",
@@ -169,7 +169,7 @@ func (s) TestHTTPHeaderFrameErrorHandlingNormalTrailer(t *testing.T) {
169169
// trailer missing grpc-status
170170
":status", "502",
171171
},
172-
errCode: codes.Internal,
172+
errCode: codes.Unknown,
173173
},
174174
{
175175
name: "malformed grpc-status-details-bin field with status 404 to be ignored due to content type",

0 commit comments

Comments
 (0)