diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e03a934..06dd9fcb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,14 +11,14 @@
### API changes on existing features (you may need to change your code)
* RESTCONF error reporting
- * Invalid api-path syntax error changed from 412 operation-failed to 404 invalid-value. For example, change from
+ * Invalid api-path syntax (eg non-matching yang) error changed from 412 operation-failed to 400 unknown-element / invalid-value. For example, change from
```
HTTP/1.1 412 Precondition Failed
{"ietf-restconf:errors":{"error":{"error-type":"protocol","error-tag":"operation-failed","error-severity":"error","error-message":"No such yang module: badmodule"}}}
```
to:
```
- HTTP/1.1 404 Not Found
+ HTTP/1.1 400 Bad Request
{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"No such yang module: badmodule"}}}
```
* Typical installation should now add a `clicon` user (as well as group)
diff --git a/lib/src/clixon_netconf_lib.c b/lib/src/clixon_netconf_lib.c
index 95c7a414..41a91f3c 100644
--- a/lib/src/clixon_netconf_lib.c
+++ b/lib/src/clixon_netconf_lib.c
@@ -332,7 +332,7 @@ netconf_bad_attribute_xml(cxobj **xret,
}
-/*! Create Netconf unknwon-attribute error XML tree according to RFC 6241 App A
+/*! Create Netconf unknown-attribute error XML tree according to RFC 6241 App A
*
* An unexpected attribute is present.
* @param[out] cb CLIgen buf. Error XML is written in this buffer
diff --git a/lib/src/clixon_xml_map.c b/lib/src/clixon_xml_map.c
index 1982515a..bbc86241 100644
--- a/lib/src/clixon_xml_map.c
+++ b/lib/src/clixon_xml_map.c
@@ -2465,12 +2465,7 @@ api_path2xpath_cvv(cvec *api_path,
else
y = yang_find_datanode(y, name);
if (y == NULL){
- if ((cberr = cbuf_new()) == NULL){
- clicon_err(OE_UNIX, errno, "cbuf_new");
- goto done;
- }
- cprintf(cberr, "Unknown element: '%s'", name);
- if (netconf_invalid_value_xml(xerr, "application", cbuf_get(cberr)) < 0)
+ if (netconf_unknown_element_xml(xerr, "application", name, "Unknown element") < 0)
goto done;
goto fail;
}
diff --git a/test/test_restconf_err.sh b/test/test_restconf_err.sh
index 70e0d8e3..c62eb413 100755
--- a/test/test_restconf_err.sh
+++ b/test/test_restconf_err.sh
@@ -19,7 +19,8 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
APPNAME=example
cfg=$dir/conf.xml
-fyang=$dir/restconf.yang
+fyang=$dir/example.yang
+fyang2=$dir/aug.yang
fxml=$dir/initial.xml
# example
@@ -27,7 +28,7 @@ cat < $cfg
$cfg
/usr/local/share/clixon
- $IETFRFC
+ $dir
$fyang
false
/usr/local/var/$APPNAME/$APPNAME.sock
@@ -36,11 +37,32 @@ cat < $cfg
EOF
+cat < $fyang2
+module augm{
+ yang-version 1.1;
+ namespace "urn:example:aug";
+ prefix aug;
+ description "Used as a base for augment";
+ container route-state {
+ description
+ "Root container for routing models";
+ config "false";
+ container dynamic {
+ }
+ }
+}
+EOF
+
cat < $fyang
module example{
yang-version 1.1;
namespace "urn:example:clixon";
prefix ex;
+ import aug {
+ description "Just for augment";
+ prefix "aug";
+ }
+
list a {
key k;
leaf k {
@@ -62,6 +84,17 @@ module example{
}
}
}
+ augment "/aug:route-config/aug:dynamic" {
+ container ospf {
+ container routers {
+ container auto-cost {
+ leaf reference-bandwidth {
+ type uint32;
+ }
+ }
+ }
+ }
+ }
}
EOF
@@ -101,12 +134,26 @@ new "restconf GET initial datastore"
expecteq "$(curl -s -X GET -H 'Accept: application/yang-data+xml' http://localhost/restconf/data/example:a)" 0 "$XML
"
-new "restconf GET non-existent container header"
-expectfn "curl -s -I -X GET http://localhost/restconf/data/example:a/c" 0 "HTTP/1.1 404 Not Found"
-
new "restconf GET non-existent container body"
-expectfn "curl -s -X GET http://localhost/restconf/data/example:a/c" 0 '{"ietf-restconf:errors":{"error":{"rpc-error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"Instance does not exist"}}}}'
+expectpart "$(curl -si -X GET http://localhost/restconf/data/example:a/c)" 0 'HTTP/1.1 404 Not Found' '{"ietf-restconf:errors":{"error":{"rpc-error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"Instance does not exist"}}}}'
+new "restconf GET invalid (no yang) container body"
+expectpart "$(curl -si -X GET http://localhost/restconf/data/example:a/xxx)" 0 'HTTP/1.1 400 Bad Request' '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"unknown-element","error-info":{"bad-element":"xxx"},"error-severity":"error","error-message":"Unknown element"}}}'
+
+new "restconf GET invalid (no yang) element"
+expectpart "$(curl -si -X GET http://localhost/restconf/data/example:xxx)" 0 'HTTP/1.1 400 Bad Request' '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"unknown-element","error-info":{"bad-element":"xxx"},"error-severity":"error","error-message":"Unknown element"}}}'
+
+if false; then
+new "restconf POST non-existent (no yang) element"
+# should be invalid element
+expectpart "$(curl -is -X POST -H 'Content-Type: application/yang-data+xml' -d "$XML" http://localhost/restconf/data/example:a=23/xxx)" 0 'HTTP/1.1 400 Bad Request' '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"Unknown element: '
+
+
+new "restconf GET multi-namespace path"
+# simplify yang
+# works for config?
+expectpart "$(curl -si -X GET http://localhost/restconf/data/augm:route-state/dynamic/ospf/routers/auto-cost/reference-bandwidth)" 0 'HTTP/1.1 404 Not Found' '{"ietf-restconf:errors":{"error":{"rpc-error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"Unknown element: 'xxx'"}}}}'
+fi
new "Kill restconf daemon"
stop_restconf