From 5fb47e129a2e5bea8a708428f6794bbb3ed2e692 Mon Sep 17 00:00:00 2001 From: Brennan Saeta Date: Wed, 20 Dec 2017 14:47:04 -0800 Subject: [PATCH] Truncate status messages before converting to gRPC. PiperOrigin-RevId: 179736746 --- tensorflow/core/distributed_runtime/rpc/grpc_util.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tensorflow/core/distributed_runtime/rpc/grpc_util.h b/tensorflow/core/distributed_runtime/rpc/grpc_util.h index ac0a33a2b9..bb85478347 100644 --- a/tensorflow/core/distributed_runtime/rpc/grpc_util.h +++ b/tensorflow/core/distributed_runtime/rpc/grpc_util.h @@ -23,6 +23,7 @@ limitations under the License. #include "grpc++/support/byte_buffer.h" #include "tensorflow/core/distributed_runtime/tensor_coding.h" #include "tensorflow/core/lib/core/status.h" +#include "tensorflow/core/lib/strings/stringprintf.h" #include "tensorflow/core/platform/mutex.h" #include "tensorflow/core/platform/protobuf.h" @@ -61,6 +62,13 @@ inline ::grpc::Status ToGrpcStatus(const ::tensorflow::Status& s) { if (s.ok()) { return ::grpc::Status::OK; } else { + if (s.error_message().size() > 3072 /* 3k bytes */) { + // TODO(b/62947679): Remove truncation once the gRPC issue is resolved. + string scratch = + strings::Printf("%.3072s ... [truncated]", s.error_message().c_str()); + LOG(ERROR) << "Truncated error message: " << s; + return ::grpc::Status(static_cast<::grpc::StatusCode>(s.code()), scratch); + } return ::grpc::Status(static_cast<::grpc::StatusCode>(s.code()), s.error_message()); } -- 2.34.1