# Yang sends old config first before sending new config

**URL:** <https://dmap-community.ductus.global/t/yang-sends-old-config-first-before-sending-new-config/3771>\
**Category:** YANG\
**Created:** [August 6, 2021, 11:35am UTC](https://dmap-community.ductus.global/t/yang-sends-old-config-first-before-sending-new-config/3771 "2021-08-06T11:35:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vivek](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@vivek](https://dmap-community.ductus.global/u/vivek)\
**Post date:** [August 6, 2021, 11:35am UTC](https://dmap-community.ductus.global/t/yang-sends-old-config-first-before-sending-new-config/3771/1 "2021-08-06T11:35:44Z")

</div>

Below is my yang file.

```
  container auth {
  tailf:info "Configure NTP authentication keys";
  list server {
    tailf:info "Configured ip addresses";
    tailf:cli-incomplete-command;
    tailf:cli-compact-syntax;
    tailf:cli-sequence-commands;
    tailf:cli-suppress-mode;
    key "serverip";

    leaf serverip {
      tailf:info "ip address";
      type leafref {
        path "/gw-system:ntp/gw-system:server" ;
       }
    }
    leaf key {
      tailf:cli-incomplete-command;
      tailf:info "Authentication key ID for this server";
      type uint32 {
        range "1..65535";
      }
    }
    choice authtype {
      mandatory "true";
      case sha256 {
        leaf en-sha256 {
        tailf:info "SHA256 encryption";
        type tailf:aes-cfb-128-encrypted-string {
          tailf:info "Cleartext Secret";
          }
        tailf:suppress-echo true;
        tailf:validate validate_ntp_auth_key_pwd {
          tailf:dependency '.';
          }
        }
      }
      case md5 {
        leaf en-md5 {
        tailf:info "MD5 encryption";
        type tailf:aes-cfb-128-encrypted-string {
          tailf:info "Cleartext Secret";
          }
        }
      }
      case md5 {
        leaf en-md5 {
        tailf:info "MD5 encryption";
        type tailf:aes-cfb-128-encrypted-string {
          tailf:info "Cleartext Secret";
          }
        tailf:suppress-echo true;
        tailf:validate validate_ntp_auth_key_pwd {
          tailf:dependency '.';
          }
        }
      }
      case sha1 {
        leaf en-sha1 {
        tailf:info "SHA1 encryption";
        type tailf:aes-cfb-128-encrypted-string {
          tailf:info "Cleartext Secret";
          }
        tailf:suppress-echo true;
        tailf:validate validate_ntp_auth_key_pwd {
          tailf:dependency '.';
          }
        }
      }
    }
 }
}

```

I am facing one small issue with yang.  
When I reconfigure the command with different values then yang sends the previous values first before sending the new values.  
For example:

ntp auth server 1.1.1.1 key 1 en-sha1 cisco  
commit  
ntp auth server 1.1.1.1 key 1 en-sha256 cisco  
commit

when I try to configure the same command with different values then I receive old values first followed by new values.  
The problem with this is that yang sends the old values with confd\_vtype as 1 which is C\_NOEXISTS because of this my applciation gets crash because my application expect that the type will always be C\_BUF

How can I make yang to understand that if the same command is configured with different values then always send new values instead of sending old values first?

---

<div class="post-metadata">

**Author:** ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)\
**Post date:** [August 6, 2021, 11:48pm UTC](https://dmap-community.ductus.global/t/yang-sends-old-config-first-before-sending-new-config/3771/2 "2021-08-06T23:48:48Z")

</div>

I assume you are referring to the oldv parameter from the cdb\_diff\_iterate() iter function.  
Makes sense for your use case that the old value is of type C\_NOEXISTS as the choice case did not exist before the pending transaction.  
Start a new read-session to the CDB\_PRE\_COMMIT\_RUNNING database to find out which case was set and the value of the content before the pending transaction.
