clicon / clixon

YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI
http://www.clicon.org/
Other
216 stars 72 forks source link

Inconsistent error messages for out of range values #567

Open devibinoy opened 1 week ago

devibinoy commented 1 week ago

set instance default protocol bgp timer keepalive 99999999999999999999 CLI syntax error: "set instance default protocol bgp timer keepalive 99999999999999999999": Number 99999999999999999999 out of data-type range: 0 - 18446744073709551615

set instance default protocol bgp timer keepalive 99999
CLI syntax error: "set instance default protocol bgp timer keepalive 99999": Number 99999 out of data-type range: 0 - 65535

Here, keepalive is of type uint16. The logic parses the input first as a broader type (uint64), and then as the specific type (uint16). However, the error messages are inconsistent between these stages for the same context.

olofhagsand commented 3 days ago

The logic is done in match_variable: https://github.com/clicon/cligen/blob/68a0b407f5c4e1fd81191ad1eb8be5fe640ad03d/cligen_match.c#L92 It has to do with split functionality in the parse and validate functions making the range checks unnecessary complex. One way to fix it could to add explicit range checks in the parse function.