# Any difference between an empty list and an list not presence?

**URL:** <https://dmap-community.ductus.global/t/any-difference-between-an-empty-list-and-an-list-not-presence/3978>\
**Category:** CDB and CDB API\
**Created:** [January 29, 2022, 5:54am UTC](https://dmap-community.ductus.global/t/any-difference-between-an-empty-list-and-an-list-not-presence/3978 "2022-01-29T05:54:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hzpfly](https://avatars.discourse-cdn.com/v4/letter/h/f04885/32.png) [@hzpfly](https://dmap-community.ductus.global/u/hzpfly)\
**Post date:** [January 29, 2022, 5:54am UTC](https://dmap-community.ductus.global/t/any-difference-between-an-empty-list-and-an-list-not-presence/3978/1 "2022-01-29T05:54:48Z")

</div>

Hi ConfD supports,  
In the example intro/1-2-3-start-query-model of ConfD User Guide, here is the configuration before deleting:

```auto
admin@C00006605% show dhcp
shared-networks {
    shared-network n1;
}

```

No configuration found after running command `delete dhcp shared-networks shared-network n1`:

```auto
admin@C00006605% show configuration dhcp
No entries found.
[ok][2022-01-29 13:36:15]

```

Here is the yang file:

```auto
  container dhcp {
    leaf default-lease-time {
      type xs:duration;
      default PT600S;
    }
    leaf max-lease-time {
      type xs:duration;
      default PT7200S;
    }
    leaf log-facility {
      type loglevel;
      default local7;
    }
    container subnets {
      uses subnet;
    }
    container shared-networks {
      list shared-network {
        key name;
        max-elements 1024;
        leaf name {
          type string;
        }
        container subnets {
          uses subnet;
        }
      }
    }
  }

```

The container `dhcp` and `shared-networks` is a non-presence container, but the list `shared-network` has no presence or non-presence attribute. My question is:

> In the implementation of CDB, the empty list is deleted when deleting the last entry of the list.  
> Do you think is there any difference between empty list and an list not present in configuration?  
> Any reason or standard choosing this implementation?

BRs  
Michael

---

<div class="post-metadata">

**Author:** ![josephm](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@josephm](https://dmap-community.ductus.global/u/josephm)\
**Post date:** [January 31, 2022, 9:50am UTC](https://dmap-community.ductus.global/t/any-difference-between-an-empty-list-and-an-list-not-presence/3978/2 "2022-01-31T09:50:12Z")

</div>

Imho not a choice, but following the standard - [list statement](https://datatracker.ietf.org/doc/html/rfc7950#section-7.8)

`presence` concept is defined only for `container` in RFC, and there is no similar concept for the `list` nodes…

---

<div class="post-metadata">

**Author:** ![hzpfly](https://avatars.discourse-cdn.com/v4/letter/h/f04885/32.png) [@hzpfly](https://dmap-community.ductus.global/u/hzpfly)\
**Post date:** [February 7, 2022, 2:55am UTC](https://dmap-community.ductus.global/t/any-difference-between-an-empty-list-and-an-list-not-presence/3978/3 "2022-02-07T02:55:39Z")

</div>

Hi @josephm  
Thank you for your reply. But I am afraid there is no clear descriptions in the standard you mentioned whether to delete the empty list when deleting the last entry of a list.  
For example, suppose the list is [“a”]. If we delete the unique entry “a”, then the list becomes empty, which is []. Should we also delete the empty list?

---

<div class="post-metadata">

**Author:** ![josephm](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@josephm](https://dmap-community.ductus.global/u/josephm)\
**Post date:** [February 7, 2022, 8:42am UTC](https://dmap-community.ductus.global/t/any-difference-between-an-empty-list-and-an-list-not-presence/3978/4 "2022-02-07T08:42:10Z")

</div>

There are two levels in relation to data model:

- abstract data model schema
- actual data/configuration state ​

`list` is defined only for former, just like non-presence `container`, or `choice`/`case` statements.  
It does not have definition of “existence” or “absence” in the actual data state anywhere in RFC… There is no “deletion” of list being done in the CLI → you are actually deleting “all the list entries”, not list per se.

If the device data model needs to model difference between “empty list” and “no list” on the data level, you may need e.g. to combine presence container with list inside.

---

<div class="post-metadata">

**Author:** ![josephm](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@josephm](https://dmap-community.ductus.global/u/josephm)\
**Post date:** [February 7, 2022, 8:54am UTC](https://dmap-community.ductus.global/t/any-difference-between-an-empty-list-and-an-list-not-presence/3978/5 "2022-02-07T08:54:14Z")

</div>

> [@hzpfly](#):
>
> For example, suppose the list is [“a”]. If we delete the unique entry “a”, then the list becomes empty, which is . Should we also delete the empty list?

This assumes that there is a definition/differentiation of empty/non-empty list on RFC level, which is unfortunately not true. ☹  
If ConfD did implement this “narrowing down the rules defined in RFC”, it could lead to conflicts with other YANG RFC tools/dameons, that would not implement the detail in same manner…

Difference on data level can be mapped e.g. as described in my previous comment.

If it’s about specific need for CLI output, there are various `tailf_yang_cli_extensions` annotations that modify how data model displays in CLI. This can help to finetune to end-user needs, e.g. showing “empty list” when no entries are present. This behavior is however specific to CLI only, and other northbound APIs like RESTCONF or NETCONF are not affected…
