From 5c2a3942d98383539dc66d4d45abbaf5554a4f3b Mon Sep 17 00:00:00 2001 From: Jeremie Leska Date: Fri, 27 Nov 2026 09:28:54 +0100 Subject: [PATCH] data: log the xpath of the missing key in the list Give the schema path of the object during the exception. Signed-off-by: Jeremie Leska --- libyang/data.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libyang/data.py b/libyang/data.py index 712ed76..68a155d 100644 --- a/libyang/data.py +++ b/libyang/data.py @@ -1490,8 +1490,10 @@ def _to_dnode(_dic, _schema, _parent=ffi.NULL, in_rpc_output=False): try: key_values.append(val.pop(k)) except KeyError as e: - raise ValueError("Missing key %s in the list" % (k)) from e - + raise ValueError( + "%s: missing key %r in list element: %r" + % (s.schema_path(), k, v) + ) from e n = _create_list(_parent, module, name, key_values, in_rpc_output) _to_dnode(val, s, n, in_rpc_output)