Page MenuHomeVyOS Platform

validate-value prints error messages from validators that fail even if overall validation succeeds
Confirmed, Unbreak Now!PublicBUG

Description

Having the following validation statement in https://github.com/vyos/vyos-1x/blob/current/interface-definitions/service_router-advert.xml.in for e.g.

<leafNode name="valid-lifetime">
  <properties>
    <help>Time in seconds that the prefix will remain valid (default: 30 days)</help>
    <completionHelp>
      <list>infinity</list>
    </completionHelp>
    <valueHelp>
      <format>1-4294967295</format>
      <description>Time in seconds that the prefix will remain valid</description>
    </valueHelp>
    <valueHelp>
      <format>infinity</format>
      <description>Prefix will remain preferred forever</description>
    </valueHelp>
    <constraint>
      <validator name="numeric" argument="--range 0-4294967295"/>
      <regex>(infinity)</regex>
    </constraint>
  </properties>
  <defaultValue>2592000</defaultValue>
</leafNode>

Will print: 'infinity' is not a valid integer number but the value is accepted. How can we both validate a string an an integer for the same node?

Details

Difficulty level
Unknown (require assessment)
Version
1.3-rolling-20200803
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Perfectly compatible

Event Timeline

Before adding "<defaultValue>" it was working but not now.

I tried

<constraint>
  <validator name="numeric" argument="--range 0-4294967295"/>
  <validator name="fqdn"/>
  <regex>(infinity)</regex>
</constraint>

2 validators also don't work.

I would have expected the output generated to be an OR of the validators or regexes and allow the output if any would have passed it

We can add a new <constraintGroup> element. If you put multiple <constraint> elements inside a <constraintGroup>, they work like logical AND.

If you have both <constraint> and <constraintGroup> elements under <properties>, a value must be valid for either that single constraint or the group.

This actually also happens for BGP which will confuse users

vyos@vyos# set protocols bgp 100 neighbor 1.1.1.1 remote-as internal
    'internal' is not a valid integer number
c-po renamed this task from XML: router-adver: validate both string (regex) and number to XML: router-advert, bgp: multiple different validators cause error message to pop up even if syntax is valid.Jan 17 2021, 4:31 PM
c-po changed the task status from Open to Confirmed.
c-po assigned this task to dmbaturin.
c-po triaged this task as Unbreak Now! priority.
dmbaturin renamed this task from XML: router-advert, bgp: multiple different validators cause error message to pop up even if syntax is valid to validate-value prints error messages from validators that fail even if overall validation succeeds.Feb 18 2021, 12:43 PM
dmbaturin changed Is it a breaking change? from Unspecified (possibly destroys the router) to Perfectly compatible.
dmbaturin added subscribers: SrividyaA, rherold, ronie and 2 others.

Some notes from past meetings.

XML - current implementation:

<constraint>
  <validator name="numeric" argument="--range 1-65535"/>
</constraint>

XML - new implementation:

<constraint>
  .. validator node 1 ...
  <errorMessage>This is bad</errorMessage>
</constraint>
<constraint>
  .. validator node 2 ...
  <errorMessage>This is bad</errorMessage>
</constraint>

Only once <validator> should be supported per <constraint>

<constraintGroup>
  .. validator node 1 ...
  .. validator node 2 ...
  <errorMessage>This is bad</errorMessage>
</constraintGroup>

All constraints in <constraint> are run as logical OR, all validators under the <constraintGroup> node are run with a logical AND.

Having both constraint and constraintGroup will OR both together