From ac7480b9f52840a215a7e76993c4dd37ae9690ec Mon Sep 17 00:00:00 2001 From: Olof Hagsand Date: Mon, 5 Mar 2018 19:59:43 +0000 Subject: [PATCH] * Invalid key to api_path2xml gives warning instead of error and quit. --- CHANGELOG.md | 1 + apps/cli/cli_show.c | 3 +++ lib/src/clixon_xml_map.c | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a300d032..45fdb979 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Major changes: ### Minor changes: +* Invalid key to api_path2xml gives warning instead of error and quit. * yang_find_topnode() and api_path2xml() schemanode parameter replaced with yang_class. Replace as follows: 0 -> YC_DATANODE, 1 -> YC_SCHEMANODE * xml2json: include prefix in translation, so is translated to {"a:b" ..} diff --git a/apps/cli/cli_show.c b/apps/cli/cli_show.c index d3569aa6..7106965f 100644 --- a/apps/cli/cli_show.c +++ b/apps/cli/cli_show.c @@ -173,6 +173,8 @@ expand_dbvar(void *h, */ if (api_path && api_path2xml(api_path, yspec, xtop, YC_DATANODE, &xbot, &y) < 0) goto done; + if (y==NULL) + goto ok; /* Special case for leafref. Detect leafref via Yang-type, * Get Yang path element, tentatively add the new syntax to the whole * tree and apply the path to that. @@ -236,6 +238,7 @@ expand_dbvar(void *h, /* XXX RFC3986 decode */ cvec_add_string(commands, NULL, bodystr); } + ok: retval = 0; done: if (api_path) diff --git a/lib/src/clixon_xml_map.c b/lib/src/clixon_xml_map.c index 5f2e6b7b..577fd298 100644 --- a/lib/src/clixon_xml_map.c +++ b/lib/src/clixon_xml_map.c @@ -1614,8 +1614,8 @@ api_path2xml(char *api_path, int nvec; if (*api_path!='/'){ - clicon_err(OE_DB, 0, "Invalid key: %s", api_path); - goto done; + clicon_log(LOG_WARNING, "Invalid key: %s (must start with '/')", api_path); + goto ok; } if ((vec = clicon_strsep(api_path, "/", &nvec)) == NULL) goto done; @@ -1631,6 +1631,7 @@ api_path2xml(char *api_path, xtop, (yang_node*)yspec, nodeclass, xbotp, ybotp) < 0) goto done; + ok: retval = 0; done: if (vec)