Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[yang]Static route CLI command adds empty nexthop-vrf which results in yang validation failure #21352

Open
dgsudharsan opened this issue Jan 8, 2025 · 0 comments
Labels
YANG YANG model related changes

Comments

@dgsudharsan
Copy link
Collaborator

Description

When configuring static route through CLI, if nexthop-vrf is not configured, an empty string is set as value

https://github.com/sonic-net/sonic-utilities/blob/7100f73b107b5a7806488311e224e6be29c6b412/config/main.py#L7032

However the yang validation mandates nexthop-vrf to be a valid vrf string as per the pattern.

pattern "(((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)),)*((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt))";

Hence when we config static route through CLI, save and perform config reload, it results in yang validation failure

  "STATIC_ROUTE|default|50.0.0.0/24": {
    "expireat": 1736209448.6722484,
    "ttl": -0.001,
    "type": "hash",
    "value": {
      "blackhole": "false",
      "distance": "0",
      "ifname": "",
      "nexthop": "20.0.0.2",
      "nexthop-vrf": ""
    }
  },
2025 Jan  7 02:20:27.950607 r-anaconda-51 INFO database.sh[4827]: libyang[0]: Value "" does not satisfy the constraint "(((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)),)*((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt))" (range, length, or pattern). (path: /sonic-static-route:sonic-static-route/STATIC_ROUTE/STATIC_ROUTE_LIST[vrf_name='default'][prefix='50.0.0.0/24']/nexthop-vrf)
2025 Jan  7 02:20:27.951583 r-anaconda-51 ERR sonic_yang: Data Loading Failed:Value "" does not satisfy the constraint "(((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)),)*((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt))" (range, length, or pattern).
2025 Jan  7 02:20:27.951682 r-anaconda-51 ERR config_validator.py: Yang validation failed: Data Loading Failed#012Value "" does not satisfy the constraint "(((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)),)*((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt))" (range, length, or pattern).
2025 Jan  7 02:20:27.951759 r-anaconda-51 INFO database.sh[4827]: sonic_yang(3):Data Loading Failed:Value "" does not satisfy the constraint "(((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)),)*((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt))" (range, length, or pattern).
2025 Jan  7 02:20:27.951805 r-anaconda-51 INFO database.sh[4827]: Traceback (most recent call last):
2025 Jan  7 02:20:27.951842 r-anaconda-51 INFO database.sh[4827]:   File "/usr/local/lib/python3.11/dist-packages/sonic_yang_ext.py", line 1176, in loadData
2025 Jan  7 02:20:27.954680 r-anaconda-51 INFO database.sh[4827]:     self.root = self.ctx.parse_data_mem(dumps(self.xlateJson), \
2025 Jan  7 02:20:27.954754 r-anaconda-51 INFO database.sh[4827]:                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025 Jan  7 02:20:27.954781 r-anaconda-51 INFO database.sh[4827]:   File "/usr/lib/python3/dist-packages/yang.py", line 2574, in parse_data_mem
2025 Jan  7 02:20:27.956987 r-anaconda-51 INFO database.sh[4827]:     return _yang.Context_parse_data_mem(self, data, format, options)
2025 Jan  7 02:20:27.957072 r-anaconda-51 INFO database.sh[4827]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025 Jan  7 02:20:27.957100 r-anaconda-51 INFO database.sh[4827]: RuntimeError: Value "" does not satisfy the constraint "(((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)),)*((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt))" (range, length, or pattern).
2025 Jan  7 02:20:27.957122 r-anaconda-51 INFO database.sh[4827]: During handling of the above exception, another exception occurred:
2025 Jan  7 02:20:27.957142 r-anaconda-51 INFO database.sh[4827]: Traceback (most recent call last):
2025 Jan  7 02:20:27.957162 r-anaconda-51 INFO database.sh[4827]:   File "/usr/local/bin/config_validator.py", line 44, in <module>
2025 Jan  7 02:20:27.957188 r-anaconda-51 INFO database.sh[4827]:     main()
2025 Jan  7 02:20:27.957218 r-anaconda-51 INFO database.sh[4827]:   File "/usr/local/bin/config_validator.py", line 33, in main
2025 Jan  7 02:20:27.957289 r-anaconda-51 INFO database.sh[4827]:     yang_parser.loadData(configdbJson=config)
2025 Jan  7 02:20:27.957319 r-anaconda-51 INFO database.sh[4827]:   File "/usr/local/lib/python3.11/dist-packages/sonic_yang_ext.py", line 1183, in loadData
2025 Jan  7 02:20:27.957542 r-anaconda-51 INFO database.sh[4827]:     raise SonicYangException("Data Loading Failed\n{}".format(str(e)))
2025 Jan  7 02:20:27.957587 r-anaconda-51 INFO database.sh[4827]: sonic_yang_ext.SonicYangException: Data Loading Failed
2025 Jan  7 02:20:27.957611 r-anaconda-51 INFO database.sh[4827]: Value "" does not satisfy the constraint "(((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)),)*((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt))" (range, length, or pattern).

Steps to reproduce the issue:

  1. config static route through CLI
  2. config save
  3. config reload

Describe the results you received:

Config reload fails in yang validation

Describe the results you expected:

config reload should not fail.

Output of show version:

(paste your output here)

Output of show techsupport:

(paste your output here or download and attach the file here )

Additional information you deem important (e.g. issue happens only occasionally):

@dgsudharsan dgsudharsan added the YANG YANG model related changes label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
YANG YANG model related changes
Projects
None yet
Development

No branches or pull requests

1 participant