* Fixed: Some restconf errors were wrongly formatted such as: {"ietf-restconf:errors":{"error":{"rpc-error": . There should be no "rpc-error" level.
This commit is contained in:
parent
a71c256898
commit
86e251f30b
3 changed files with 35 additions and 9 deletions
|
|
@ -73,6 +73,7 @@ Expected: February 2020
|
||||||
|
|
||||||
### Corrected Bugs
|
### Corrected Bugs
|
||||||
|
|
||||||
|
* Fixed: Some restconf errors were wrongly formatted such as: `{"ietf-restconf:errors":{"error":{"rpc-error":` . There should be no `"rpc-error"` level.
|
||||||
* Fixed: Enabling modstate (CLICON_XMLDB_MODSTATE), changing a revision on a yang, and restarting made the backend daemon exit at start (thanks Matt)
|
* Fixed: Enabling modstate (CLICON_XMLDB_MODSTATE), changing a revision on a yang, and restarting made the backend daemon exit at start (thanks Matt)
|
||||||
* Also: ensure to load `ietf-yang-library.yang ` if CLICON_XMLDB_MODSTATE is set
|
* Also: ensure to load `ietf-yang-library.yang ` if CLICON_XMLDB_MODSTATE is set
|
||||||
* Fixed: Pretty-printed XML using prefixes not parsed correctly.
|
* Fixed: Pretty-printed XML using prefixes not parsed correctly.
|
||||||
|
|
|
||||||
|
|
@ -468,18 +468,41 @@ api_return_err(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cbuf *cb = NULL;
|
cbuf *cb = NULL;
|
||||||
|
cbuf *cberr = NULL;
|
||||||
cxobj *xtag;
|
cxobj *xtag;
|
||||||
char *tagstr;
|
char *tagstr;
|
||||||
int code;
|
int code;
|
||||||
|
cxobj *xerr2 = NULL;
|
||||||
const char *reason_phrase;
|
const char *reason_phrase;
|
||||||
|
|
||||||
clicon_debug(1, "%s", __FUNCTION__);
|
clicon_debug(1, "%s", __FUNCTION__);
|
||||||
if ((cb = cbuf_new()) == NULL)
|
if ((cb = cbuf_new()) == NULL){
|
||||||
|
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||||
goto done;
|
goto done;
|
||||||
if ((xtag = xpath_first(xerr, NULL, "//error-tag")) == NULL){
|
|
||||||
restconf_notfound(r);
|
|
||||||
goto ok;
|
|
||||||
}
|
}
|
||||||
|
/* A well-formed error message when entering here should look like:
|
||||||
|
* <rpc-error>...<error-tag>invalid-value</error-tag>
|
||||||
|
* Check this is so, otherwise generate an internal error.
|
||||||
|
*/
|
||||||
|
if (strcmp(xml_name(xerr), "rpc-error") != 0 ||
|
||||||
|
(xtag = xpath_first(xerr, NULL, "error-tag")) == NULL){
|
||||||
|
if ((cberr = cbuf_new()) == NULL){
|
||||||
|
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
cprintf(cberr, "Internal error, system returned invalid error message: ");
|
||||||
|
if (netconf_err2cb(xerr, cberr) < 0)
|
||||||
|
goto done;
|
||||||
|
if (netconf_operation_failed_xml(&xerr2, "application",
|
||||||
|
cbuf_get(cberr)) < 0)
|
||||||
|
goto done;
|
||||||
|
if ((xerr = xpath_first(xerr2, NULL, "//rpc-error")) == NULL){
|
||||||
|
clicon_err(OE_XML, 0, "Internal error, shouldnt happen");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (xml_name_set(xerr, "error") < 0)
|
||||||
|
goto done;
|
||||||
tagstr = xml_body(xtag);
|
tagstr = xml_body(xtag);
|
||||||
if (code0 != 0)
|
if (code0 != 0)
|
||||||
code = code0;
|
code = code0;
|
||||||
|
|
@ -489,8 +512,6 @@ api_return_err(clicon_handle h,
|
||||||
}
|
}
|
||||||
if ((reason_phrase = restconf_code2reason(code)) == NULL)
|
if ((reason_phrase = restconf_code2reason(code)) == NULL)
|
||||||
reason_phrase="";
|
reason_phrase="";
|
||||||
if (xml_name_set(xerr, "error") < 0)
|
|
||||||
goto done;
|
|
||||||
FCGX_SetExitStatus(code, r->out); /* Created */
|
FCGX_SetExitStatus(code, r->out); /* Created */
|
||||||
FCGX_FPrintF(r->out, "Status: %d %s\r\n", code, reason_phrase);
|
FCGX_FPrintF(r->out, "Status: %d %s\r\n", code, reason_phrase);
|
||||||
FCGX_FPrintF(r->out, "Content-Type: %s\r\n\r\n", restconf_media_int2str(media));
|
FCGX_FPrintF(r->out, "Content-Type: %s\r\n\r\n", restconf_media_int2str(media));
|
||||||
|
|
@ -532,12 +553,14 @@ api_return_err(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
break;
|
break;
|
||||||
} /* switch media */
|
} /* switch media */
|
||||||
ok:
|
// ok:
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
clicon_debug(1, "%s retval:%d", __FUNCTION__, retval);
|
clicon_debug(1, "%s retval:%d", __FUNCTION__, retval);
|
||||||
if (cb)
|
if (cb)
|
||||||
cbuf_free(cb);
|
cbuf_free(cb);
|
||||||
|
if (cberr)
|
||||||
|
cbuf_free(cberr);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -263,8 +263,10 @@ api_data_get2(clicon_handle h,
|
||||||
if (netconf_invalid_value_xml(&xerr, "application", "Instance does not exist") < 0)
|
if (netconf_invalid_value_xml(&xerr, "application", "Instance does not exist") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* override invalid-value default 400 with 404 */
|
/* override invalid-value default 400 with 404 */
|
||||||
if (api_return_err(h, r, xerr, pretty, media_out, 404) < 0)
|
if ((xe = xpath_first(xerr, NULL, "rpc-error")) != NULL){
|
||||||
goto done;
|
if (api_return_err(h, r, xe, pretty, media_out, 404) < 0)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
switch (media_out){
|
switch (media_out){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue