Subject: [netmod] updates to issue list

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 03 Jul 2014 19:53:53 +0200

Hi,

I committed the following changes to the YANG 1.1 issue list:

- alternative solution Y10-02

- example showing that solution Y18-01 doesn't work reliably.

I am copying the example here so that we can discuss it:

   leaf A {
     when "../B = 1";
     mandatory true;
     ...
   }
   leaf B {
     when "../C = 2";
     type uint8;
     default 1;
   }
   leaf C {
     type uint8;
   }

   Now, if an instance document (repository) doesn't contain A and B
   but C is present with the value of 2, then

   1. If the server starts with checking node A, then B is not present, so
      mandatory statement doesn't apply => the document is valid. 
   2. But if the server starts with checking node B, then its "when"
      expression is true, the default applies and the "when"
      expression for A becomes true => the document is invalid. 

Lada

-- 
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C

---

From: Martin Bjorklund <[email-masked]>
Date: Thu, 03 Jul 2014 23:03:06 +0200 (CEST)

>       expression for A becomes true => the document is invalid. 

Three comments:

1.  This has nothing to do with the context node problem.  You get the
    same "problem" if you use absolute paths to the leafs:

      leaf A {
        when "/B = 1";
        ...
      }
      leaf B {
        when "/C = 1";
      }

2.  We have already agreed that it is possible to write stupid
    models.  For example it is legal to write:

      leaf X {
        mandatory true;
        must "1 = 2";
      }

    which leads to a situation where anything you try to configure is
    illegal.

3.  Andy has pointed out several times how 'when' evaluation is
    tricky to implement.

    In the example above, you cannot simply pick an order and evaluate
    the when expressions in that order.  You have to follow the
    dependencies.  So, the interpretation is:  since C is 2, leaf B's
    default value is in effect, and thus leaf A's mandatory statement
    applies, and the instance document is invalid (since A was not
    present).

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Fri, 4 Jul 2014 08:36:51 +0200

> 1.  This has nothing to do with the context node problem.  You get the

Of course it does. The context nodes are always A and B, no matter what the expression is. And if the context node is missing, the XPath expression is ill-defined.

>    same "problem" if you use absolute paths to the leafs:

Yes, same problem. Note, however, that with “must” instead of “when” everything is fine.

>    which leads to a situation where anything you try to configure is

First, this example is different because its result is deterministic - every implementation must classify any document containing X as invalid.

Second, a chain of “when” dependencies is far less stupid than this example - and the nodes can be in different modules.
 
> 3.  Andy has pointed out several times how 'when' evaluation is

Yes, because the document schema depends on the particular document being validated.

I think “when” is really useful only on augments. Otherwise, “must” semantics works mostly fine, except the case of “when” being attached to a mandatory node. 

>    applies, and the instance document is invalid (since A was not

So the solution to Y18 should describe the procedure in more detail.

I do agree though that circular dependencies of “when” expressions should not normally happen (should be banned in the spec).

Lada