From 6ad606cb9ad49ca7bfb8056b9695ab271a33e790 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= <tomas.pecka@cesnet.cz>
Date: Wed, 26 Mar 2025 18:56:06 +0100
Subject: [PATCH 35/44] make sure that edit tree is the first sibling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Organization: Wires

After a bug in velia [1], where we passed to Session::editBatch a tree
which was not the first sibling (and this caused that all the left
siblings of the node were not considered in the edit), I am making sure
that we do not lose any data in this project due to this too.

[1] https://github.com/CESNET/velia/commit/2b7187405740fe61e8b37e0efab8c3173d398a26

Fixes: 25f3e3b ("restconf: support for YANG patch")
Change-Id: I7211168325fbfddd75dc1520c9dd83e31138d3bc
Signed-off-by: Mattias Walström <lazzer@gmail.com>
---
 src/restconf/Server.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/restconf/Server.cpp b/src/restconf/Server.cpp
index 05239e9..c454541 100644
--- a/src/restconf/Server.cpp
+++ b/src/restconf/Server.cpp
@@ -600,7 +600,7 @@ void processYangPatchEdit(const std::shared_ptr<RequestContext>& requestCtx, con
     if (!mergedEdits) {
         mergedEdits = *singleEdit;
     } else {
-        mergedEdits->insertSibling(*singleEdit);
+        mergedEdits = mergedEdits->insertSibling(*singleEdit); // make sure we point to the first sibling, sysrepo::editBatch requires that
     }
 }
 
-- 
2.43.0

