data tree BUGFIX error check instead of assert
Fixes sysrepo/sysrepo#2278
diff --git a/src/tree_data.c b/src/tree_data.c
index 38dd22d..c904370 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1378,7 +1378,15 @@
schema->module->name, strlen(schema->module->name), NULL, 0, NULL, LY_PREF_JSON, NULL,
LYD_NODEHINT_LIST, &node), cleanup);
} else {
- assert(p[path_idx].pred_type == LY_PATH_PREDTYPE_LIST);
+ if (p[path_idx].pred_type != LY_PATH_PREDTYPE_LIST) {
+ LOG_LOCSET(schema, NULL, NULL, NULL);
+ LOGVAL(ctx, LYVE_XPATH, "Predicate missing for %s \"%s\" in path \"%s\".",
+ lys_nodetype2str(schema->nodetype), schema->name, path);
+ LOG_LOCBACK(1, 0, 0, 0);
+ ret = LY_EINVAL;
+ goto cleanup;
+ }
+
LY_CHECK_GOTO(ret = lyd_create_list(schema, p[path_idx].predicates, &node), cleanup);
}
break;