diff --git a/lib/src/clixon_validate.c b/lib/src/clixon_validate.c
index 5ff366c9..11fe11f0 100644
--- a/lib/src/clixon_validate.c
+++ b/lib/src/clixon_validate.c
@@ -669,8 +669,24 @@ check_list_key(cxobj *xt,
while ((cvi = cvec_each(cvk, cvi)) != NULL) {
keyname = cv_string_get(cvi);
if (xml_find_type(xt, NULL, keyname, CX_ELMNT) == NULL){
- if (xret && netconf_missing_element_xml(xret, "application", keyname, "Mandatory key") < 0)
- goto done;
+ if (xret){
+ cbuf *cb = NULL;
+ yang_stmt *ymod;
+ enum rfc_6020 keyw;
+
+ if ((cb = cbuf_new()) == NULL){
+ clicon_err(OE_UNIX, errno, "cbuf_new");
+ goto done;
+ }
+ ymod = ys_module(yt);
+ keyw = yang_keyword_get(yt);
+ cprintf(cb, "Mandatory key in '%s %s' in %s.yang:%d",
+ yang_key2str(keyw), xml_name(xt), yang_argument_get(ymod),
+ yang_linenum_get(yc));
+ if (netconf_missing_element_xml(xret, "application", keyname, cbuf_get(cb)) < 0)
+ goto done;
+ cbuf_free(cb);
+ }
goto fail;
}
}
diff --git a/test/test_netconf.sh b/test/test_netconf.sh
index c50416c1..dc4de610 100755
--- a/test/test_netconf.sh
+++ b/test/test_netconf.sh
@@ -223,7 +223,7 @@ new "Re-Delete eth/0/0 using none should generate error"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0ex:ethnone " "" ""
new "Add interface without key"
-expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "ex:ethnone " "" "applicationmissing-elementnameerrorMandatory key"
+expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "ex:ethnone " "" "applicationmissing-elementnameerrorMandatory key in 'list interface' in ietf-interfaces.yang:107"
new "netconf discard-changes"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" ""
diff --git a/test/test_restconf_op.sh b/test/test_restconf_op.sh
index 6c90d286..847e4d66 100755
--- a/test/test_restconf_op.sh
+++ b/test/test_restconf_op.sh
@@ -102,7 +102,7 @@ new "wait restconf"
wait_restconf
new "restconf POST tree without key"
-expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"example:cont1":{"interface":{"type":"regular"}}}' $RCPROTO://localhost/restconf/data)" 0 "HTTP/$HVER 400" '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"missing-element","error-info":{"bad-element":"name"},"error-severity":"error","error-message":"Mandatory key"}}}'
+expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"example:cont1":{"interface":{"type":"regular"}}}' $RCPROTO://localhost/restconf/data)" 0 "HTTP/$HVER 400" "{\"ietf-restconf:errors\":{\"error\":{\"error-type\":\"application\",\"error-tag\":\"missing-element\",\"error-info\":{\"bad-element\":\"name\"},\"error-severity\":\"error\",\"error-message\":\"Mandatory key in 'list interface' in example.yang:7\"}}}"
new "restconf POST initial tree"
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"example:cont1":{"interface":{"name":"local0","type":"regular"}}}' $RCPROTO://localhost/restconf/data)" 0 "HTTP/$HVER 201"
@@ -134,7 +134,7 @@ new "restconf POST interface without mandatory type"
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/example:cont1 -d '{"example:interface":{"name":"TEST"}}')" 0 "HTTP/$HVER 400" '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"missing-element","error-info":{"bad-element":"type"},"error-severity":"error","error-message":"Mandatory variable of interface in module example"}}}'
new "restconf POST interface without mandatory key"
-expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/example:cont1 -d '{"example:interface":{"type":"regular"}}')" 0 "HTTP/$HVER 400" '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"missing-element","error-info":{"bad-element":"name"},"error-severity":"error","error-message":"Mandatory key"}}}'
+expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/example:cont1 -d '{"example:interface":{"type":"regular"}}')" 0 "HTTP/$HVER 400" "{\"ietf-restconf:errors\":{\"error\":{\"error-type\":\"application\",\"error-tag\":\"missing-element\",\"error-info\":{\"bad-element\":\"name\"},\"error-severity\":\"error\",\"error-message\":\"Mandatory key in 'list interface' in example.yang:7\"}}}"
new "restconf POST interface"
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"example:interface":{"name":"TEST","type":"eth0"}}' $RCPROTO://localhost/restconf/data/example:cont1)" 0 "HTTP/$HVER 201"
diff --git a/test/test_rpc.sh b/test/test_rpc.sh
index c34034d0..d70d8b28 100755
--- a/test/test_rpc.sh
+++ b/test/test_rpc.sh
@@ -345,7 +345,7 @@ expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "mandatory$LIST" "" "applicationmissing-elementukerrorMandatory key"
+expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "mandatory$LIST" "" "applicationmissing-elementukerrorMandatory key in 'list u1' in clixon-example.yang:62"
LIST='bar1bar2'
new "netconf example rpc input list with non-unique keys (should fail)"