How to access list element on the key which is empty

I work on implementation of ietf-alarms.yang data model. Here is the fragment that I am struggling with:

container alarms {
  container alarm-inventory {
    config false;
    list alarm-type {
      key "alarm-type-id alarm-type-qualifier";
      leaf alarm-type-id {
        type alarm-type-id;
      }
      leaf alarm-type-qualifier {
        type alarm-type-qualifier;
      }
      leaf-list resource {
        type resource-match;
      }
      leaf will-clear {
        type boolean;
        mandatory true;
      }

List alarm-type has 2 keys:
alarm-type-id - evaluates to identity ref
alarm-type-qualifier - evaluates to string

According to RFC8632 the alarm-type-qualifier is optional, which means it could be empty string.

My question is: how to access elements of the list with empty alarm-type-qualifier from CLI?
Here is CLI output:

ubuntudsk1# show alarms alarm-inventory alarm-type test-alarm “” will-clear
------------------------------------------------------------------------------------------------^
syntax error: unknown argument

The syntax is correct, but I believe the problem is that there is no instance alarm-type{test-alarm ""} provided by your data provider:

box# show alarms alarm-inventory alarm-type              
            ALARM                                                                  PROBABLE  
ALARM TYPE  TYPE                 WILL   SEVERITY                  EVENT  PROBABLE  CAUSE     
ID          QUALIFIER  RESOURCE  CLEAR  LEVEL        DESCRIPTION  TYPE   CAUSE     STRING    
---------------------------------------------------------------------------------------------
link-alarm             -         false  [ warning ]  -            -      -         -         
link-alarm  abcd       -         -      -            -            -      -         -         

box# show alarms alarm-inventory alarm-type link-alarm ""
            ALARM                                                                  PROBABLE  
ALARM TYPE  TYPE                 WILL   SEVERITY                  EVENT  PROBABLE  CAUSE     
ID          QUALIFIER  RESOURCE  CLEAR  LEVEL        DESCRIPTION  TYPE   CAUSE     STRING    
---------------------------------------------------------------------------------------------
link-alarm             -         false  [ warning ]  -            -      -         -         

box# show alarms alarm-inventory alarm-type link-alarm efgh
--------------------------------------------^
syntax error: unknown argument
box# 

I use callpoint to provide data. It successfully returns the list but not individual element. Any suggestion where to look? Thank you.

ubuntudsk1# show alarms alarm-inventory alarm-type              
            ALARM                                                                                            
ALARM TYPE  TYPE                 WILL                                                                        
ID          QUALIFIER  RESOURCE  CLEAR  SEVERITY LEVEL                    DESCRIPTION                        
------------------------------------------------------------------------------------------------------------- 
test-alarm             [ any ]   true   [ warning minor major critical ]  Test alarm  

ubuntudsk1# show alarms alarm-inventory alarm-type test-alarm ""
--------------------------------------------------------------^
syntax error: unknown argument

I suspect you do not implement get_elem correctly. This callback needs to response to an invocation with a path like /alarms/alarm-inventory/alarm-type{X Y}/alarm-type-id (or generally, for any list the data provider needs to be able to handle get_elem targeted at the list’s first key element). ConfD uses this to verify whether given instance exists and your DP needs to respond with the key value if it does, or not_found if it does not.

Se developerLogLevel to trace and have a look at your devel.log, ConfD logs every callback request/response there.

I double checked my code. It seems it implemented according to documentation. There is nothing suspicious in devel.log. Still it doesn’t behave like in your example.
Is it possible to get your code to compare with mine to see what’s wrong on my side. Could you upload please or send it to me?
Thank you.

Also check your application libconfd trace log with log level set to “CONFD_TRACE”. And why not upload your code?

I used the alarm data model but let ConfD to keep the data in its operational CDB, to verify there is nothing odd with the data model. But you can have a look at the intro/5-c_stats example; it uses the arp table as the source of operational data, but with minor tweaking you can feed it your data with "" for an empty “interface name”:

@@ -113,7 +113,7 @@
 
     free_arp(dp);
 
-    if ((fp = popen("arp -an", "r")) == NULL)
+    if ((fp = popen("cat /tmp/arplist", "r")) == NULL)
         return CONFD_ERR;
     while (fgets(&buf[0], BUFSIZ, fp) != NULL) {
         char *cp = strtok(&buf[0], sep);
@@ -169,7 +169,11 @@
         /* cp should now point to the interface name
            - this is required since it is a key */
         if (cp) {
-            ae->iface = strdup(cp);
+            if (strcmp(cp, "\"\"") == 0) {
+                ae->iface = strdup("");
+            } else {
+                ae->iface = strdup(cp);
+            }
 
             /* Some OSes have perm/pub after interface name */
             while ((cp = strtok(NULL, sep)) != NULL) {

You can verify it works fine with these changes and you can do stuff like

box# show arpentries arpe 10.0.0.23 "" permanent 
permanent false
box# 

Eventually I figured out the problem, took me almost a week. If you put the following into confd.conf then you can reproduce the problem on your end.

     <cli>
         <enableDisplayLevel>true</enableDisplayLevel>
     </cli>

I am not sure about the purpose of this option and also have no idea how it ended up in my confd.conf
but it screwing things big time.
Thanks for the support.

You can use GitHub flavoured Markdown for making, for example, XML readable in your posts https://guides.github.com/features/mastering-markdown/