From dd6207e99ab45fa85073d60ca22fdd9c7527f8ff Mon Sep 17 00:00:00 2001 From: ydynnikov Date: Fri, 27 Feb 2026 11:19:31 +0300 Subject: Enhance library/cpp/monlib exception verbosity for debugging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Этот эксепшн ронял YDB RU PRESTABLE минимум дважды: \- 2025-09-10 \- 2026-02-19 Патч призван упростить отладку падений и поиски руткоза commit_hash:72d859bae3ab265a2807e566c763bfb70a92a61a --- library/cpp/monlib/encode/json/json_encoder.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'library/cpp/monlib/encode/json/json_encoder.cpp') diff --git a/library/cpp/monlib/encode/json/json_encoder.cpp b/library/cpp/monlib/encode/json/json_encoder.cpp index 2af058155a8..4394685512c 100644 --- a/library/cpp/monlib/encode/json/json_encoder.cpp +++ b/library/cpp/monlib/encode/json/json_encoder.cpp @@ -11,6 +11,7 @@ #include #include +#include namespace NMonitoring { namespace { @@ -174,8 +175,12 @@ namespace NMonitoring { } void WriteLabel(TStringBuf name, TStringBuf value) { - Y_ENSURE(IsUtf(name), "label name is not valid UTF-8 string"); - Y_ENSURE(IsUtf(value), "label value is not valid UTF-8 string"); + if (!IsUtf(name)) { + ythrow yexception() << "label name is not valid UTF-8 string: '" << EscapeC(name.SubStr(0, 100)) << "'"; + } else if (!IsUtf(value)) { + ythrow yexception() << "label value is not valid UTF-8 string, name: '" << name << "', value: '" << EscapeC(value.SubStr(0, 100)) << "'"; + } + if (Style_ == EJsonStyle::Cloud && name == MetricNameLabel_) { CurrentMetricName_ = value; } else { -- cgit v1.3