* Second fix of https://github.com/clicon/clixon/issues/158
* Actually there is an error of duplicate rpc-replies, but it should be detected in the backend not here
This commit is contained in:
parent
3c014184f7
commit
344dcacf6f
3 changed files with 13 additions and 5 deletions
|
|
@ -418,6 +418,10 @@ api_return_err(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if 1
|
||||||
|
if (clicon_debug_get())
|
||||||
|
clicon_log_xml(LOG_DEBUG, xerr, "%s Send error:", __FUNCTION__);
|
||||||
|
#endif
|
||||||
if (xml_name_set(xerr, "error") < 0)
|
if (xml_name_set(xerr, "error") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
tagstr = xml_body(xtag);
|
tagstr = xml_body(xtag);
|
||||||
|
|
@ -431,7 +435,7 @@ api_return_err(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
switch (media){
|
switch (media){
|
||||||
case YANG_DATA_XML:
|
case YANG_DATA_XML:
|
||||||
clicon_debug(1, "%s code:%d err:%s", __FUNCTION__, code, cbuf_get(cb));
|
clicon_debug(1, "%s code:%d", __FUNCTION__, code);
|
||||||
if (pretty){
|
if (pretty){
|
||||||
cprintf(cb, " <errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">\n");
|
cprintf(cb, " <errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">\n");
|
||||||
if (clicon_xml2cbuf(cb, xerr, 2, pretty, -1) < 0)
|
if (clicon_xml2cbuf(cb, xerr, 2, pretty, -1) < 0)
|
||||||
|
|
@ -446,7 +450,7 @@ api_return_err(clicon_handle h,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case YANG_DATA_JSON:
|
case YANG_DATA_JSON:
|
||||||
clicon_debug(1, "%s code:%d err:%s", __FUNCTION__, code, cbuf_get(cb));
|
clicon_debug(1, "%s code:%d", __FUNCTION__, code);
|
||||||
if (pretty){
|
if (pretty){
|
||||||
cprintf(cb, "{\n\"ietf-restconf:errors\" : ");
|
cprintf(cb, "{\n\"ietf-restconf:errors\" : ");
|
||||||
if (xml2json_cbuf(cb, xerr, pretty) < 0)
|
if (xml2json_cbuf(cb, xerr, pretty) < 0)
|
||||||
|
|
|
||||||
|
|
@ -614,8 +614,13 @@ api_operations_post_output(clicon_handle h,
|
||||||
clicon_debug(1, "%s", __FUNCTION__);
|
clicon_debug(1, "%s", __FUNCTION__);
|
||||||
/* Validate that exactly only <rpc-reply> tag with exactly one element child */
|
/* Validate that exactly only <rpc-reply> tag with exactly one element child */
|
||||||
if ((xoutput = xml_child_i_type(xret, 0, CX_ELMNT)) == NULL ||
|
if ((xoutput = xml_child_i_type(xret, 0, CX_ELMNT)) == NULL ||
|
||||||
strcmp(xml_name(xoutput),"rpc-reply") != 0 ||
|
strcmp(xml_name(xoutput),"rpc-reply") != 0
|
||||||
xml_child_nr_type(xoutput, CX_ELMNT) != 1){
|
/* See https://github.com/clicon/clixon/issues/158
|
||||||
|
* This is an internal error, they should not be double but the error should not be detected
|
||||||
|
* here, it should be detected in the backend plugin caller.
|
||||||
|
|| xml_child_nr_type(xrpc, CX_ELMNT) != 1 XXX backend can have multiple callbacks
|
||||||
|
*/
|
||||||
|
){
|
||||||
if (netconf_malformed_message_xml(&xerr, "restconf RPC does not have single input") < 0)
|
if (netconf_malformed_message_xml(&xerr, "restconf RPC does not have single input") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if ((xe = xpath_first(xerr, NULL, "rpc-error")) == NULL){
|
if ((xe = xpath_first(xerr, NULL, "rpc-error")) == NULL){
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,6 @@ expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+xml
|
||||||
# Here running is empty
|
# Here running is empty
|
||||||
new "Check running empty"
|
new "Check running empty"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data/></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data/></rpc-reply>]]>]]>$"
|
||||||
exit
|
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
new "Kill backend"
|
new "Kill backend"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue