diff options
| author | mikari <[email protected]> | 2026-02-16 13:39:23 +0300 |
|---|---|---|
| committer | mikari <[email protected]> | 2026-02-16 14:14:45 +0300 |
| commit | 5039b832c55d6551d443b41c1121fee3053461ba (patch) | |
| tree | ce5d186136bd98dbae507f35a36d03b2528c61e4 | |
| parent | a28c3451813b29d7e963da741906adfe7327737f (diff) | |
Partial fix of TError deserialization from yson
commit_hash:11bf8dd585c156b7dc1bddaf33266a4ac73557a3
| -rw-r--r-- | yt/yt/core/ytree/serialize-inl.h | 7 | ||||
| -rw-r--r-- | yt/yt/core/ytree/unittests/serialize_ut.cpp | 9 |
2 files changed, 14 insertions, 2 deletions
diff --git a/yt/yt/core/ytree/serialize-inl.h b/yt/yt/core/ytree/serialize-inl.h index 8cfb07ba59f..8e3bbcdc151 100644 --- a/yt/yt/core/ytree/serialize-inl.h +++ b/yt/yt/core/ytree/serialize-inl.h @@ -648,14 +648,17 @@ void Deserialize(google::protobuf::RepeatedField<T>& value, INodePtr node) template <class T> void Deserialize(TErrorOr<T>& error, NYTree::INodePtr node) { - TError& justError = error; + TError justError = error; Deserialize(justError, node); - if (error.IsOK()) { + if (justError.IsOK()) { + error = TErrorOr(T()); auto mapNode = node->AsMap(); auto valueNode = mapNode->FindChild("value"); if (valueNode) { Deserialize(error.Value(), std::move(valueNode)); } + } else { + error = std::move(justError); } } diff --git a/yt/yt/core/ytree/unittests/serialize_ut.cpp b/yt/yt/core/ytree/unittests/serialize_ut.cpp index b897b6b9a37..5b08d927223 100644 --- a/yt/yt/core/ytree/unittests/serialize_ut.cpp +++ b/yt/yt/core/ytree/unittests/serialize_ut.cpp @@ -470,6 +470,15 @@ TEST(TSerializationTest, PlainEnum) TestSerializationDeserialization(static_cast<EVanillaTestEnum>(42)); } +TEST(TSerializationTest, TError) +{ + TestSerializationDeserialization(TError()); + TestSerializationDeserialization(TErrorOr<ui64>(5ull)); + // TODO: TError internal structure is lost during serialization/deserialization process right now. + // TestSerializationDeserialization(TError("some error")); + // TestSerializationDeserialization(TErrorOr<ui64>(TError("some error"))); +} + TEST(TYTreeSerializationTest, Protobuf) { NProto::TTestMessage message; |
