From 906b93cae0a5c340fc0385dbaccd4c12831f07d5 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Fri, 18 Jan 2019 20:55:30 +0100 Subject: [PATCH] Restconf returns error when RPC generates "ok" reply [https://github.com/clicon/clixon/issues/69] --- CHANGELOG.md | 1 + apps/netconf/netconf_rpc.c | 8 +++++++- apps/restconf/restconf_methods.c | 11 +++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 124fd3a13..9b2b756a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -134,6 +134,7 @@ * properly + * (2) Uncertain how validation errors should be logged/handled + */ + if (0) if ((youtput = yang_find((yang_node*)yrpc, Y_OUTPUT, NULL)) != NULL){ xoutput=xpath_first(*xret, "/"); xml_spec_set(xoutput, youtput); /* needed for xml_spec_populate */ if (xml_apply(xoutput, CX_ELMNT, xml_spec_populate, yspec) < 0) goto done; + if ((ret = xml_yang_validate_all_top(xoutput, cbret)) < 0) goto done; if (ret == 0){ diff --git a/apps/restconf/restconf_methods.c b/apps/restconf/restconf_methods.c index 754592c97..2ab68aee3 100644 --- a/apps/restconf/restconf_methods.c +++ b/apps/restconf/restconf_methods.c @@ -1390,7 +1390,7 @@ api_operations_post_output(clicon_handle h, } #endif /* Validate output (in case handlers are wrong) */ - if (youtput==NULL){ + if (youtput==NULL){ /* Special case, no yang output * RFC 7950 7.14.4 * If the RPC operation invocation succeeded and no output parameters @@ -1428,10 +1428,17 @@ api_operations_post_output(clicon_handle h, } else{ xml_spec_set(xoutput, youtput); /* needed for xml_spec_populate */ + if (0){ + /* Sanity check of outgoing XML + * For now, skip outgoing checks. + * (1) Does not handle properly + * (2) Uncertain how validation errors should be logged/handled + */ if (xml_apply(xoutput, CX_ELMNT, xml_spec_populate, yspec) < 0) goto done; if ((ret = xml_yang_validate_all(xoutput, cbret)) < 0) goto done; + if (ret == 1 && (ret = xml_yang_validate_add(xoutput, cbret)) < 0) goto done; @@ -1446,7 +1453,7 @@ api_operations_post_output(clicon_handle h, goto done; goto fail; } - + } /* Clear namespace of parameters */ x = NULL; while ((x = xml_child_each(xoutput, x, CX_ELMNT)) != NULL) {