Page MenuHomeVyOS Platform

`vyos.config.exists()` does not work for nodes with multiple values
Closed, ResolvedPublicBUG


The exists() function ( uses only return_value, so it works only for nodes with a single value.
We have at least one confirmed issue because of this:

To make it compatible with nodes with multiple values, we should add also return_values. Basic proof-of-concept:

diff --git a/python/vyos/ b/python/vyos/
index a5c1ad12..09c8fd03 100644
--- a/python/vyos/
+++ b/python/vyos/
@@ -164,7 +164,11 @@ class Config(object):
             path_str = " ".join(path_without_value)
                 value = self._session_config.return_value(self._make_path(path_str))
-                return (value == path[-1])
+                values = self._session_config.return_values(self._make_path(path_str))
+                if value and path[-1] == value:
+                    return True
+                if isinstance(values, list) and path[-1] in values:
+                    return True
             except vyos.configtree.ConfigTreeError:
                 # node doesn't exist at all
                 return False


Difficulty level
Easy (less than an hour)
1.4-rolling-202204130521, 1.3.1-S1
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Perfectly compatible
Issue type
Bug (incorrect behavior)

Event Timeline

jestabro changed the task status from Open to Backport candidate.Apr 15 2022, 10:57 AM
jestabro moved this task from Need Triage to Finished on the VyOS 1.4 Sagitta board.
jestabro changed the task status from Backport candidate to Open.Apr 22 2022, 4:13 PM
jestabro moved this task from Finished to In Progress on the VyOS 1.4 Sagitta board.

Re-open for revision/simplification in: