One question about the leaf default usage

Hi,
I have a question about the leaf’s default usage, use the below exampe to show it.

  1. The yang module:
# cat default.yang
module default{
  namespace "http://complex/default";
  prefix "default";
  container test1 {
     list test2{
        key id;
        leaf id{
          type uint8 {
              range "1..80";
          }
        }
        leaf type{
           type enumeration {
              enum "Act";
              enum "Term";
           }
           default "Act";
        }
        leaf trace{
           when "../type = 'Act'";
           type enumeration {
              enum "URI";
              enum "Number";
           }
           default "Number";
         }
         leaf name{
           must "not(../trace = 'URI')";
           type string;
        }
      }
    }
 } 
  1. The XML file:
 # cat default.xml 
  <test1 xmlns="http://complex/default">
    <test2>
      <id>1</id>
      <type>Act</type>
      <trace>Number</trace>
      <name>abc</name>
    </test2>
    <test2>
      <id>2</id>
      <type>Term</type>
    </test2>
  </test1>
  1. The edit-config result will report error.
# /root/lab-5/confd/bin/netconf-console  --port=2022 --edit-config default.xml 
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <rpc-error>
    <error-type>application</error-type>
    <error-tag>unknown-element</error-tag>
    <error-severity>error</error-severity>
    <error-path xmlns:default="http://complex/default">
    /rpc/edit-config/config/default:test1/default:test2[default:id='2']/default:trace
  </error-path>
    <error-message xml:lang="en">/test1/test2[id='2']/trace: the 'when' expression "../type = 'Act'" failed</error-message>
    <error-info>
      <bad-element>trace</bad-element>
    </error-info>
  </rpc-error>
</rpc-reply>
  1. My question is:
    In the RFC7950 RFC 7950 - The YANG 1.1 Data Modeling Language, the below description shows the default value won’t be used if the when condition is false. But the above error seems it still use the default value.

Note that if the leaf or any of its ancestors has a “when” condition
or “if-feature” expression that evaluates to “false”, then the
default value is not in use.

note: Only the leaf name contains the must check which uses the leaf trace will trigger the when error(i.e.if I remove the must check in the leaf name, the above when error won’t be reported), I didn’t find in the RFC that the default valude is in use if the leaf is referred by other value.

What ConfD release are you using? I tried this with several releases down to 6.3, in all of them the edit-config request passed without any errors.

Hi @mvf,
My ConfD version is 6.2, maybe my release is too old.

# ./confd --version
6.2

Yes, I would think so. confd-6.2 was released 3 years ago, and 6 months younger confd-6.3 handles this correctly.