From 213793230f22651510710ec53310d92c3e1a220c Mon Sep 17 00:00:00 2001 From: Arjan Singh Bal <46515553+arjan-bal@users.noreply.github.com> Date: Fri, 24 Jan 2025 10:23:17 +0530 Subject: [PATCH] grpc: Fix encoded message size reported in error message (#8033) --- rpc_util.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpc_util.go b/rpc_util.go index 94160b130897..f2b8a555b49d 100644 --- a/rpc_util.go +++ b/rpc_util.go @@ -692,9 +692,9 @@ func encode(c baseCodec, msg any) (mem.BufferSlice, error) { if err != nil { return nil, status.Errorf(codes.Internal, "grpc: error while marshaling: %v", err.Error()) } - if uint(b.Len()) > math.MaxUint32 { + if bufSize := uint(b.Len()); bufSize > math.MaxUint32 { b.Free() - return nil, status.Errorf(codes.ResourceExhausted, "grpc: message too large (%d bytes)", len(b)) + return nil, status.Errorf(codes.ResourceExhausted, "grpc: message too large (%d bytes)", bufSize) } return b, nil }