From dfe256e964b2fb527960e50cbb8c8da6365dbd03 Mon Sep 17 00:00:00 2001
From: Malte Bauch <malte.bauch@stud.h-da.de>
Date: Tue, 14 Mar 2023 17:02:48 +0100
Subject: [PATCH] Fix: failing commits while applying changes on the network
 element

If read-only fields are sent to the network element with a SetRequest an
error is thrown by the network element. This can be prevented by
filtering all the read-only fields with the help of
`ygot.PruneConfigFalse` - since they are not needed in a SetRequest.
---
 plugins/sdk/deviceModel.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/plugins/sdk/deviceModel.go b/plugins/sdk/deviceModel.go
index 5f97186d3..218233b52 100644
--- a/plugins/sdk/deviceModel.go
+++ b/plugins/sdk/deviceModel.go
@@ -176,6 +176,10 @@ func (d *DeviceModel) Diff(original, modified []byte) (*gpb.Notification, error)
 		return nil, err
 	}
 
+	//TODO: This should be changed to be optional
+	ygot.PruneConfigFalse(d.schema.RootSchema(), originalAsValidatedCopy)
+	ygot.PruneConfigFalse(d.schema.RootSchema(), modifiedAsValidatedCopy)
+
 	return ygot.Diff(originalAsValidatedCopy, modifiedAsValidatedCopy)
 }
 
-- 
GitLab