Closed sindhukothe closed 5 years ago
Yes, I've noticed that as well. I suppose an empty string is technically valid, but it seems like it defeats the purpose of defining a description
statement in the schema if it's not going to contain any meaningful value.
True. But I am not the one writing these yangs :)
What YANG module has this? Let me loop in @llhotka to get his thoughts on dealing with this.
Empty description should be possible, I will check the parsing rules.
The parser seems to accept empty descriptions, both single- and double quoted.
No problem on the parser side:
$ coffee check_submodule.coffee Cisco-IOS-XR-ipv4-bgp-oper-sub1.yang
Submodule OK.
Thanks @llhotka for your verification. The issue is on yang-js
side, it is enforcing that the argument exists... I'll fix on my end.
@llhotka - the issue is that the parser currently returns an empty string both for when the argument is an empty string and when there is no argument.
coffee> parser = require 'yang-parser'
coffee> parser.parse 'description "";'
YangStatement { prf: '', kw: 'description', arg: '', substmts: [] }
coffee> parser.parse 'description;'
YangStatement { prf: '', kw: 'description', arg: '', substmts: [] }
coffee> parser.parse 'input {}'
YangStatement { prf: '', kw: 'input', arg: '', substmts: [] }
coffee> parser.parse 'input "" {}'
YangStatement { prf: '', kw: 'input', arg: '', substmts: [] }
I was previously treating empty arg
string as non-existence which was presenting the issue as described in this ticket. If I allow empty arg
string from the yang-parser
then I will need a way to differentiate between a legitimate empty arg string vs undefined argument. Can you have the yang-parser
return arg: undefined/null
if no argument found during parsing?
When the description field is empty string e.g. description "" Parser is throwing exception. This seems like a valid syntax, but I am not sure.