# CLI tab completion not work in list configurations with multiple keys

**URL:** https://dmap-community.ductus.global/t/cli-tab-completion-not-work-in-list-configurations-with-multiple-keys/3605
**Category:** Core Engine and APIs
**Created:** [April 20, 2021, 10:56am UTC](https://dmap-community.ductus.global/t/cli-tab-completion-not-work-in-list-configurations-with-multiple-keys/3605 "2021-04-20T10:56:29Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Fei.Du](https://avatars.discourse-cdn.com/v4/letter/f/278dde/32.png) [@Fei.Du](https://dmap-community.ductus.global/u/Fei.Du)
#### Post date: [April 20, 2021, 10:56am UTC](https://dmap-community.ductus.global/t/cli-tab-completion-not-work-in-list-configurations-with-multiple-keys/3605/1 "2021-04-20T10:56:29Z")

</div>

Hi,

CLI tab completion not work in some list with multiple keys.  
If the list is not marked as ordered-by user in the YANG data model, the tab completion not work with the second key.

The callbacks are triggered in different ways for ordered-by user list an no ordered-by user list:

No ordered-by user list callbacks:

> TRACE CALL data get\_next(thandle=35, /tab-completion/plmn, -1)  
> → CONFD\_OK  
> TRACE CALL data get\_next(thandle=35, /tab-completion/plmn, 0)  
> → CONFD\_OK  
> TRACE CALL data get\_next(thandle=35, /tab-completion/plmn, -1)  
> → CONFD\_OK  
> TRACE CALL data get\_next(thandle=35, /tab-completion/plmn, 0)  
> → CONFD\_OK  
> TRACE CALL data get\_elem(thandle=35,/tab-completion/plmn{400 “”}/mcc)  
> (NOEXISTS) → CONFD\_OK  
> TRACE CALL data find\_next\_object(thandle=35, /tab-completion/plmn, same\_or\_next, {400})  
> → CONFD\_OK

ordered-by user list callbacks:

> TRACE CALL data get\_next(thandle=35, /plmn, -1)  
> → CONFD\_OK  
> TRACE CALL data get\_next(thandle=35, /plmn, 0)  
> → CONFD\_OK  
> TRACE CALL data get\_next(thandle=35, /plmn, -1)  
> → CONFD\_OK  
> TRACE CALL data get\_next(thandle=35, /plmn, 0)  
> → CONFD\_OK  
> TRACE CALL data get\_elem(thandle=35,/plmn{400 “”}/mcc)  
> (NOEXISTS) → CONFD\_OK  
> TRACE CALL data get\_next(thandle=35, /plmn, -1)  
> → CONFD\_OK  
> TRACE CALL data get\_next(thandle=35, /plmn, 0)  
> → CONFD\_OK

Is this a bug in ConfD? How to make tab completion work on not ordered-by user list with multiple keys?

Thanks!

---

<div class="post-metadata">

### Author: ![Fei.Du](https://avatars.discourse-cdn.com/v4/letter/f/278dde/32.png) [@Fei.Du](https://dmap-community.ductus.global/u/Fei.Du)
#### Post date: [April 22, 2021, 5:53am UTC](https://dmap-community.ductus.global/t/cli-tab-completion-not-work-in-list-configurations-with-multiple-keys/3605/2 "2021-04-22T05:53:56Z")

</div>

Hi,

Could you tell if the ConfD triggered callbacks are correct? Or do you need more information on this?

Thanks!

---

<div class="post-metadata">

### Author: ![mvf](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mvf/32/182_2.png) [@mvf](https://dmap-community.ductus.global/u/mvf)
#### Post date: [April 22, 2021, 8:29am UTC](https://dmap-community.ductus.global/t/cli-tab-completion-not-work-in-list-configurations-with-multiple-keys/3605/3 "2021-04-22T08:29:15Z")

</div>

I don’t see any buggy behavior on ConfD side - it is common that ConfD iterates over list instances several times, especially when CLI interaction is in play. But I see something that looks like a bug in your data provider, you posted this:

```auto
 TRACE CALL data get_elem(thandle=35,/plmn{400 “”}/mcc)
(NOEXISTS) --> CONFD_OK

```

This is most likely incorrect, the instance `/plmn{400 ""}` was presumably retrieved in one of the previous `get_next` invocations and `mcc` is the list’s first key. ConfD uses this kind of callback to verify list instance and your data provider needs to reply with the key value (if the instance indeed exists). See also [here](http://dmap-community.ductus.global/t/how-to-access-list-element-on-the-key-which-is-empty/3602/4).

---

<div class="post-metadata">

### Author: ![Fei.Du](https://avatars.discourse-cdn.com/v4/letter/f/278dde/32.png) [@Fei.Du](https://dmap-community.ductus.global/u/Fei.Du)
#### Post date: [April 22, 2021, 9:50am UTC](https://dmap-community.ductus.global/t/cli-tab-completion-not-work-in-list-configurations-with-multiple-keys/3605/4 "2021-04-22T09:50:29Z")

</div>

Do you think the kp "/plmn{400 “”}/mcc is correct in get\_elem callback?  
This callback is triggered by press tab in below CLI command:  
`user1@test#show running-config tab-completion plmn 400 <tab>`

---

<div class="post-metadata">

### Author: ![mvf](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mvf/32/182_2.png) [@mvf](https://dmap-community.ductus.global/u/mvf)
#### Post date: [April 22, 2021, 10:43am UTC](https://dmap-community.ductus.global/t/cli-tab-completion-not-work-in-list-configurations-with-multiple-keys/3605/5 "2021-04-22T10:43:56Z")

</div>

I think it it correct. Is `mcc` the first key of the list `plmn`? If so, then it is the instance existence check, as I wrote, and your application needs to handle it correctly; more severe problems than just malfunctioning tab-completion can be expected otherwise.

---

<div class="post-metadata">

### Author: ![Fei.Du](https://avatars.discourse-cdn.com/v4/letter/f/278dde/32.png) [@Fei.Du](https://dmap-community.ductus.global/u/Fei.Du)
#### Post date: [April 22, 2021, 10:54am UTC](https://dmap-community.ductus.global/t/cli-tab-completion-not-work-in-list-configurations-with-multiple-keys/3605/6 "2021-04-22T10:54:59Z")

</div>

Yes, mcc is the first key of list plmn.

How to reply the instance existence check callback? Reply all the instances with first key matching with 400?  
Because there is no such instance mapping with kp /plmn{400 “”}/mcc. When press tab, we expect to get the prompt on second key, as below:

> user1@test#show running-config tab-completion plmn 400  
> Possible match completions:  
> name  
> Possible completions:  
> 1 |

yang model:

> ```
> container tab-completion {
> list plmn {
> key "mcc mnc";
> leaf mcc {
> type string;
> }
> leaf mnc {
> type string;
> }
> leaf name {
> type string;
> }
> }
> }
> 
> ```

instances:

> {  
> “tab-completion”: {  
> “plmn”: [  
> {  
> “mcc”: 400,  
> “mnc”: 1,  
> “name”: “O2”  
> }  
> ]  
> }  
> }

---

<div class="post-metadata">

### Author: ![mvf](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mvf/32/182_2.png) [@mvf](https://dmap-community.ductus.global/u/mvf)
#### Post date: [April 22, 2021, 11:39am UTC](https://dmap-community.ductus.global/t/cli-tab-completion-not-work-in-list-configurations-with-multiple-keys/3605/7 "2021-04-22T11:39:07Z")

</div>

I see. So what is going on that when you press TAB after "plmn 400 " ConfD first checks whether there is an instance with `mcc="400"` and `mnc=""`. Your data provider responded with `NOEXISTS` (which is actually correct, I was wrong before), and ConfD now needs to find possible values for `mnc`.

In case of a user-ordered list, there is not much else it can do than to run `get_next` over the list. In case of a system-ordered list, however, ConfD can speed that up by using `find_next` or `find_next_object`, if those callbacks are registered. Your data provider appears to register `find_next_object`, so ConfD calls it.

---

<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: [April 22, 2021, 1:22pm UTC](https://dmap-community.ductus.global/t/cli-tab-completion-not-work-in-list-configurations-with-multiple-keys/3605/8 "2021-04-22T13:22:03Z")

</div>

Your find\_next\_object() callback seems to be broken. See your application libconfd trace log.

---

<div class="post-metadata">

### Author: ![Fei.Du](https://avatars.discourse-cdn.com/v4/letter/f/278dde/32.png) [@Fei.Du](https://dmap-community.ductus.global/u/Fei.Du)
#### Post date: [April 22, 2021, 2:41pm UTC](https://dmap-community.ductus.global/t/cli-tab-completion-not-work-in-list-configurations-with-multiple-keys/3605/9 "2021-04-22T14:41:31Z")

</div>

Thanks for clarify how callbacks work in this scenario!

We can focus on our implementation of the find\_next\_object() callback now.

---

<div class="post-metadata">

### Author: ![Harshitha](https://avatars.discourse-cdn.com/v4/letter/h/b5e925/32.png) [@Harshitha](https://dmap-community.ductus.global/u/Harshitha)
#### Post date: [April 5, 2024, 7:22am UTC](https://dmap-community.ductus.global/t/cli-tab-completion-not-work-in-list-configurations-with-multiple-keys/3605/10 "2024-04-05T07:22:41Z")

</div>

Hi,

i’m able to see possible completions if ? is given but not when tab is pressed

any idea?
