Question about "when" usage

Hello,
I have a question about “when”, I will share my demo YANG and xml file below:

test.yang

module test{
  namespace "http://yang/test";
  prefix "test";

  container testA {
    leaf node{
        type string;
    }
    container testB {
      when "../node = 'ABC'";
      list routing {
        key "week";
        leaf week {
          type string;
        }
      }
    }
  }
}

test.xml

<testA xmlns="http://yang/test">
	<node>DEF</node>
	<testB>
		<routing>
			<week>Monday</week>
		</routing>
	</testB>
</testA>

When I use netconf-console to send above xml as RPC request to Confd server, it will return ok response.
By get-config operation, it will return below message:

<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <data>
    <testA xmlns="http://yang/test">
      <node>DEF</node>
    </testA>
  </data>
</rpc-reply>

> Blockquote

I just wonder why it will not through /testA/testB doesn’t match “when” condition? And it will write a part of xml data into datastore?
Thanks.

I think your question is similar to A question about the "when" merge usage

As @cohult described:

As an edit-config is applied as one transaction (not per operation), a NETCONF server will process that transaction and after that processing, if any node’s “when” expression becomes false, then the node in the data tree with the “when” expression is deleted by the server.

Hi @mnovak,
In the issue link: A question about the "when" merge usage - #3 by darcyl, the db has contained the node’s configuration data and when another XML modifies the data, then the node with the when is deleted
In this example, the node’s configuration data isn’t stored in the db, so I think the error-message in when should be reported, not sure whether the understanding is right?

RFC 7950 - The YANG 1.1 Data Modeling Language, In the RFC, it also said if a configuration data is modified which leads to the when expression false.

If a request modifies a configuration data node such that any
node’s “when” expression becomes false, then the node in the data
tree with the “when” expression is deleted by the server.

Hi,
This is a known issue that was corrected in ConfD 7.
Premium users got ConfD 7.1 on April 24 2019 (and maintenance releases such as 6.7.4 etc). I don’t know what the status is regarding making ConfD 7.1 available for basic users.

Using MAAPI (in the same way as with NETCONF) the correct behaviour, here using ConfD 7.1.1, would be something like this:

$ confd_cmd -dd -c 'mctrans; mset /testA/node "DEF"; mcreate /testA/testB/routing{week="Monday"}; mcommit; ccommit;'
mctrans ; mset "/testA/node" "DEF" ; mcreate "/testA/testB/routing{week="Monday"}" ; mcommit ; ccommit
TRACE Connected (maapi) to ConfD
TRACE MAAPI_START_USER_SESSION  --> CONFD_OK
TRACE MAAPI_START_TRANS  --> CONFD_OK
TRACE MAAPI_SET_ELEM2 /testA/node --> CONFD_OK
TRACE MAAPI_CREATE /testA/testB/routing{week="Monday"}DEBUG item does not exist - /wf:testA/testB/routing{"week=\"Monday\""}: the 'when' expression "../node = 'ABC'" failed
 --> CONFD_ERR
FAILED: maapi_create(ms, mtid, argv[0]), Error: item does not exist (1): /wf:testA/testB/routing{"week=\"Monday\""}: the 'when' expression "../node = 'ABC'" failed, in function do_maapi_create, line 1451

Hi cohult,
Thanks very much for the response! I got it.
I will check the confd version.