diff --git a/server/v2/api/grpcgateway/interceptor.go b/server/v2/api/grpcgateway/interceptor.go index bc6b63b28d07..f224ac237921 100644 --- a/server/v2/api/grpcgateway/interceptor.go +++ b/server/v2/api/grpcgateway/interceptor.go @@ -2,6 +2,7 @@ package grpcgateway import ( "context" + "errors" "io" "net/http" "reflect" @@ -107,6 +108,11 @@ func (g *gatewayInterceptor[T]) ServeHTTP(writer http.ResponseWriter, request *h runtime.DefaultHTTPProtoErrorHandler(request.Context(), g.gateway, out, writer, request, status.Error(codes.InvalidArgument, "HTTP method was not POST or GET")) return } + if err != nil { + // the errors returned from the message creation methods return status errors. no need to make one here. + runtime.DefaultHTTPProtoErrorHandler(request.Context(), g.gateway, out, writer, request, err) + return + } // get the height from the header. var height uint64 @@ -140,7 +146,7 @@ func (g *gatewayInterceptor[T]) createMessageFromPostRequest(_ context.Context, return nil, status.Errorf(codes.InvalidArgument, "%v", err) } - if err = marshaler.NewDecoder(newReader()).Decode(input); err != nil && err != io.EOF { + if err = marshaler.NewDecoder(newReader()).Decode(input); err != nil && !errors.Is(err, io.EOF) { return nil, status.Errorf(codes.InvalidArgument, "%v", err) } diff --git a/server/v2/api/grpcgateway/uri.go b/server/v2/api/grpcgateway/uri.go index a2ebaf124f6b..4eed40befb70 100644 --- a/server/v2/api/grpcgateway/uri.go +++ b/server/v2/api/grpcgateway/uri.go @@ -6,8 +6,6 @@ import ( "strings" ) -const maxBodySize = 1 << 20 // 1 MB - // uriMatch contains information related to a URI match. type uriMatch struct { // QueryInputName is the fully qualified name of the proto input type of the query rpc method.