From f99c090625bc1963468d2df24a7503298cfd53b2 Mon Sep 17 00:00:00 2001
From: yang-g <yangg@google.com>
Date: Wed, 12 Aug 2015 13:20:15 -0700
Subject: [PATCH] return StatusCode::INTERNAL for proto parsing error

---
 src/cpp/proto/proto_utils.cc | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/cpp/proto/proto_utils.cc b/src/cpp/proto/proto_utils.cc
index 63f4a3a0bc..94ae5ba636 100644
--- a/src/cpp/proto/proto_utils.cc
+++ b/src/cpp/proto/proto_utils.cc
@@ -158,14 +158,13 @@ Status SerializeProto(const grpc::protobuf::Message& msg, grpc_byte_buffer** bp)
   GrpcBufferWriter writer(bp);
   return msg.SerializeToZeroCopyStream(&writer)
              ? Status::OK
-             : Status(StatusCode::INVALID_ARGUMENT,
-                      "Failed to serialize message");
+             : Status(StatusCode::INTERNAL, "Failed to serialize message");
 }
 
 Status DeserializeProto(grpc_byte_buffer* buffer, grpc::protobuf::Message* msg,
                         int max_message_size) {
   if (!buffer) {
-    return Status(StatusCode::INVALID_ARGUMENT, "No payload");
+    return Status(StatusCode::INTERNAL, "No payload");
   }
   GrpcBufferReader reader(buffer);
   ::grpc::protobuf::io::CodedInputStream decoder(&reader);
@@ -173,11 +172,11 @@ Status DeserializeProto(grpc_byte_buffer* buffer, grpc::protobuf::Message* msg,
     decoder.SetTotalBytesLimit(max_message_size, max_message_size);
   }
   if (!msg->ParseFromCodedStream(&decoder)) {
-    return Status(StatusCode::INVALID_ARGUMENT,
+    return Status(StatusCode::INTERNAL,
                   msg->InitializationErrorString());
   }
   if (!decoder.ConsumedEntireMessage()) {
-    return Status(StatusCode::INVALID_ARGUMENT, "Did not read entire message");
+    return Status(StatusCode::INTERNAL, "Did not read entire message");
   }
   return Status::OK;
 }
-- 
GitLab