validation UPDATE improve opaque node error messages
Refs #1834
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index 2909f23..90b1434 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -572,6 +572,10 @@
/* schema */
snode = lys_find_child(parent ? parent->schema : NULL, mod, opaq->name.name, 0, 0, 0);
+ if (!snode && parent && parent->schema && (parent->schema->nodetype & (LYS_RPC | LYS_ACTION))) {
+ /* maybe output node */
+ snode = lys_find_child(parent ? parent->schema : NULL, mod, opaq->name.name, 0, 0, LYS_GETNEXT_OUTPUT);
+ }
if (!snode) {
if (parent) {
LOGVAL(ctx, LYVE_REFERENCE, "Node \"%s\" not found as a child of \"%s\" node.", opaq->name.name,
diff --git a/src/validation.c b/src/validation.c
index e26f7a5..512fd24 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -1354,9 +1354,9 @@
/* opaque data */
if (!node->schema) {
- LOGVAL(LYD_CTX(node), LYVE_DATA, "Invalid opaque node \"%s\" found.", ((struct lyd_node_opaq *)node)->name.name);
+ r = lyd_parse_opaq_error(node);
LOG_LOCBACK(1, 1, 0, 0);
- return LY_EVALID;
+ return r;
}
/* no state/input/output/op data */
@@ -1841,8 +1841,7 @@
}
LYD_TREE_DFS_BEGIN(op_tree, op_node) {
if (!op_node->schema) {
- LOGVAL(LYD_CTX(op_tree), LYVE_DATA, "Invalid opaque node \"%s\" found.", LYD_NAME(op_node));
- return LY_EVALID;
+ return lyd_parse_opaq_error(op_node);
}
if ((int_opts & (LYD_INTOPT_RPC | LYD_INTOPT_ACTION | LYD_INTOPT_REPLY)) &&
diff --git a/tests/utests/data/test_validation.c b/tests/utests/data/test_validation.c
index 1a07e7f..d39100c 100644
--- a/tests/utests/data/test_validation.c
+++ b/tests/utests/data/test_validation.c
@@ -1257,7 +1257,7 @@
assert_non_null(tree);
/* Validate data as RPC request. */
assert_int_equal(LY_EVALID, lyd_validate_op(tree, NULL, LYD_TYPE_RPC_YANG, NULL));
- CHECK_LOG_CTX("Invalid opaque node \"new-password\" found.",
+ CHECK_LOG_CTX("Unsatisfied length - string \"123\" length is not allowed.",
"Data location /val-str:modify-user-password/new-password.");
ly_in_free(in, 0);
lyd_free_all(tree);