Page MenuHomeVyOS Platform

Completion helper list is not sorted
Open, LowPublicBUG

Description

Imagine the following CML snippet:

<leafNode name="table-size">
  <properties>
    <help>Maximum number of entries to keep in the ARP cache</help>
    <completionHelp>
      <list>1024 2048 4096 8192 16384 32768</list>
    </completionHelp>
    <constraint>
      <regex>(1024|2048|4096|8192|16384|32768)</regex>
    </constraint>
  </properties>
</leafNode>
$ cat /opt/vyatta/share/vyatta-cfg/templates/system/ip/arp/table-size/node.def
type: txt
help: Maximum number of entries to keep in the ARP cache
allowed: echo "1024 2048 4096 8192 16384 32768"
syntax:expression: exec "${vyos_libexec_dir}/validate-value.py --regex \'(1024|2048|4096|8192|16384|32768)\'  --value \'$VAR(@)\'"; "Invalid value"

But when using TAB for completin helper the values get mixed up:

vyos@vyos# set system ip arp table-size
Possible completions:
   <text>       Maximum number of entries to keep in the ARP cache
   1024
   16384
   2048
   32768
   4096
   8192

Details

Difficulty level
Normal (likely a few hours)
Version
1.3-rolling-201912280924
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)

Event Timeline

c-po created this task.Dec 28 2019, 10:17 AM
hard added a subscriber: hard.Jan 1 2020, 2:49 AM


Here fix

jjakob added a subscriber: jjakob.EditedApr 2 2020, 2:51 PM

The above patch breaks sorting for other nodes that contain text, not a number. We'd need some way to distinguish different node types (text, IP, number,...) and chose different sorts depending on that.

The old command definitions had a value format that was read by the completion functions through _cli_shell_api_hitems. We'd need to make the new XML definitions also create numeric nodes with type u32., then we could treat different node types differently and apply different sorts.

https://github.com/vyos/vyatta-cfg/blob/52d47827763b3ca774ae236eab3f4d2883c449fb/etc/bash_completion.d/vyatta-cfg#L511

jjakob triaged this task as Low priority.Apr 2 2020, 3:08 PM
pasik added a subscriber: pasik.Apr 2 2020, 3:34 PM